diff --git a/JNI/jninativelib.cc b/JNI/jninativelib.cc
index 91a445ee2b9efbc27078698af4c6eb6f0558656b..e02a00579ca267b7a1c04605cdcb73d068086c76 100644
--- a/JNI/jninativelib.cc
+++ b/JNI/jninativelib.cc
@@ -139,12 +139,12 @@ JNIEXPORT void JNICALL Java_org_eclipse_titan_executor_jni_JNIMiddleWare_configu
   // Fix for TR HO56282.
   if (!Jnimw::userInterface)
     return;
-  jboolean iscopy;
   if (config_file == NULL || env->GetStringLength( config_file ) == 0 ) {
     // use config string, which was generated by MainController
     MainController::configure(Jnimw::mycfg.config_read_buffer);
   }
   else {
+    jboolean iscopy;
     const char *conf_file = env->GetStringUTFChars(config_file, &iscopy);
     MainController::configure(conf_file);
     env->ReleaseStringUTFChars(config_file, conf_file);
diff --git a/common/Quadruple.cc b/common/Quadruple.cc
index 270f77fd1423c4be8b1081b4401d70fc9787b330..c2537a93cf23cbed4de23bedaafd064f1ddd4b90 100644
--- a/common/Quadruple.cc
+++ b/common/Quadruple.cc
@@ -340,8 +340,8 @@ char* QuadInterval::generate_hex_interval(unsigned char source,
     return res;
   }
 
-  bool alt = false;
   if (hi > 0) {
+    bool alt = false;
     if (s_lo != 'A') {
       res = mputprintf(res, "%c[%c-P]", s_hi, s_lo);
       s_hi++;
@@ -593,9 +593,8 @@ void QuadSet::do_negate() {
 }
 
 void QuadSet::add_negate_interval(const Quad& q1, const Quad& q2) {
-  unsigned int w;
   if (q2 >= q1) {
-    w = q2.get_value() - q1.get_value();
+    unsigned int w = q2.get_value() - q1.get_value();
     if (w > 0)
       add(new QuadInterval(q1, q2));
     else {
diff --git a/common/version.py b/common/version.py
old mode 100755
new mode 100644
diff --git a/compiler2/CompilerError.cc b/compiler2/CompilerError.cc
index c1c7a030a87fdf9be5beb2c0e843607e47d59524..3f07868b773c9635ce18c7e60467ea556b160583 100644
--- a/compiler2/CompilerError.cc
+++ b/compiler2/CompilerError.cc
@@ -261,9 +261,9 @@ namespace Common {
     va_list args)
   {
     if (!suppress_context) print_context(stderr);
-    Location my_location;
     if (tail != 0 && loc && loc->get_filename() == 0) {
       // borrow location information from the innermost context
+      Location my_location;
       my_location.set_location( *(tail->location) );
       loc = &my_location;
     }
diff --git a/compiler2/Int.cc b/compiler2/Int.cc
index 554afbce49d7d84e47c418ad391749db4a334ab7..0f388c07dadf91bfbc5cd6fc19c236dd7cf89385 100644
--- a/compiler2/Int.cc
+++ b/compiler2/Int.cc
@@ -201,14 +201,13 @@ int_val_t int_val_t::operator+(const int_val_t& right) const
   // the beginning.
   bool a_neg = is_negative();
   bool b_neg = right.is_negative();
-  bool r_neg = a_neg && b_neg;
   if (!a_neg && b_neg) return operator-(-right);
   if (a_neg && !b_neg) return right.operator-(-(*this));
   if (native_flag) {
-    long long result_;
     if (right.is_native()) {
       unsigned long long result = val.native + right.get_val();
-      result_ = val.native + right.get_val();
+      long long result_ = val.native + right.get_val();
+      bool r_neg = a_neg && b_neg;
       if (static_cast<long long>(result) != result_ ||
           (!r_neg && result_ < 0) || (r_neg && result_ > 0)) {
         // We can safely assume that the sum of two non-negative long long
diff --git a/compiler2/Type_chk.cc b/compiler2/Type_chk.cc
index 545a04831eeeb34cc5eed1412b59323af5a9608c..e9ec54f99ae99aa4c1bc75c0f65c9b2d4fc27f55 100644
--- a/compiler2/Type_chk.cc
+++ b/compiler2/Type_chk.cc
@@ -256,8 +256,8 @@ void Type::parse_attributes()
   if ((hasVariantAttrs())
       && (enable_text() || enable_raw() || enable_xer())) {
 #ifndef NDEBUG
-    const char *fn = get_fullname().c_str();
     if (rawAST_debug) {
+      const char *fn = get_fullname().c_str();
       fprintf(stderr, "parse_attributes for %s\n", fn);
     }
 #endif
@@ -2069,11 +2069,10 @@ void Type::chk_xer() { // XERSTUFF semantic check
   if (ownertype==OT_TYPE_DEF
     ||ownertype==OT_COMP_FIELD
     ||ownertype==OT_RECORD_OF) {
-    XerAttributes *newx = 0;
     if (is_ref()) {
       // Merge XER attributes from the referenced type.
       // This implements X.693amd1 clause 15.1.2
-      newx = new XerAttributes;
+      XerAttributes * newx = new XerAttributes;
       Type *t1 = get_type_refd();
       // chk_refd() (called by chk() for T_REFD) does not check
       // the referenced type; do it now. This makes it fully recursive.
diff --git a/compiler2/Typestuff.cc b/compiler2/Typestuff.cc
index c6a3c2bc5279c442e8583c2cef33e22de2499db2..ff5b661b5f7b2d90b64a27e1559201dad1cb55c7 100644
--- a/compiler2/Typestuff.cc
+++ b/compiler2/Typestuff.cc
@@ -541,9 +541,9 @@ namespace Common {
   void CTs_EE_CTs::chk_tags_seq_comp(TagCollection& coll, CompField *cf,
                                      bool is_mandatory)
   {
-    Type *type = cf->get_type();
     bool is_empty = coll.isEmpty();
     if (!is_mandatory || !is_empty) {
+      Type *type = cf->get_type();
       if (type->has_multiple_tags()) {
         Error_Context cntxt(type, "While checking tags of component `%s'",
                             cf->get_name().get_dispname().c_str());
diff --git a/compiler2/makefile.c b/compiler2/makefile.c
index 4b3636573c58ea7b76da59ac4d9843d441837555..0c42522c05d4ff83be42aa10eb9ccfdd9b4dba15 100644
--- a/compiler2/makefile.c
+++ b/compiler2/makefile.c
@@ -1622,8 +1622,8 @@ static void check_special_chars(const struct makefile_struct *makefile)
 static void add_base_dir(struct makefile_struct *makefile,
   const char *dir_name, boolean has_modules)
 {
-  struct base_dir_struct *base_dir;
   if (dir_name != NULL) {
+    struct base_dir_struct *base_dir;
     size_t i;
     for (i = 0; i < makefile->nBaseDirs; i++) {
       base_dir = makefile->BaseDirs + i;
@@ -1919,7 +1919,6 @@ static void print_makefile(struct makefile_struct *makefile)
     size_t i;
     char *user_info;
     const char* cxx;
-    const char* cpp;
     const char *rm_command = makefile->gnu_make ? "$(RM)" : "rm -f";
     FILE *fp;
     boolean run_compiler = (makefile->nASN1Modules > 0)
@@ -2103,6 +2102,7 @@ static void print_makefile(struct makefile_struct *makefile)
 
 
     if (makefile->preprocess || makefile->ttcn3preprocessor) {
+      const char* cpp;
       if (makefile->ttcn3preprocessor) {
         cpp = makefile->ttcn3preprocessor;
       } else {
diff --git a/compiler2/record.c b/compiler2/record.c
index 03e5ab7d8723c749b95ab5988a2986d7fa70dc1a..4b1c131d186846b9d47151dc4034994a7cab6ad8 100644
--- a/compiler2/record.c
+++ b/compiler2/record.c
@@ -1592,8 +1592,8 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
                taglist_idx < cur_choice->nElements; ++taglist_idx) {
             rawAST_coding_field_list *fields = cur_choice->fields + taglist_idx;
             for (field_idx = 0; field_idx < fields->nElements; ++field_idx) {
-              rawAST_coding_fields *field = fields->fields + field_idx;
               if (field_idx == 0) {
+                rawAST_coding_fields *field = fields->fields + field_idx;
                 src = mputprintf(src,
                   "  if (idx_map[%d] < 0) {\n"
                   "    negtest_confl_crosstag = TRUE;\n"
diff --git a/compiler2/subtype.cc b/compiler2/subtype.cc
index 1157f826355833b76feccd3fc5c8122647733d4c..e1a226370146915345d91857d299ac6c1c90fe25 100644
--- a/compiler2/subtype.cc
+++ b/compiler2/subtype.cc
@@ -2692,7 +2692,7 @@ bool SubType::add_ttcn_length(Ttcn::LengthRestriction *lr, size_t restriction_in
 {
   string s;
   lr->append_stringRepr(s);
-  Value *lower=NULL,*upper=NULL;
+  Value *lower=NULL;
   lr->set_my_scope(my_owner->get_my_scope());
   lr->set_fullname(my_owner->get_fullname()+".<length_restriction_"+Int2string(restriction_index)+">");
   lr->chk(Type::EXPECTED_CONSTANT);
@@ -2700,7 +2700,7 @@ bool SubType::add_ttcn_length(Ttcn::LengthRestriction *lr, size_t restriction_in
   if (!lower->get_my_scope()) FATAL_ERROR("no scope");
   if (lower->get_valuetype() != Value::V_INT) return false;
   if (lr->get_is_range()) {
-    upper = lr->get_upper_value();
+    Value *upper = lr->get_upper_value();
     if (upper) {//HAS_UPPER
       if (upper->get_valuetype()!=Value::V_INT) return false;
       if (!upper->get_my_scope()) upper->set_my_scope(my_owner->get_my_scope());
diff --git a/compiler2/tcov2lcov.cc b/compiler2/tcov2lcov.cc
index 0bd798cd4454199b84d7ebf7cf2e87d982a6ab57..c74902b64cbfd29ff549ef20bc709a2b6b8fa3aa 100644
--- a/compiler2/tcov2lcov.cc
+++ b/compiler2/tcov2lcov.cc
@@ -336,14 +336,13 @@ int main(int argc, char *argv[])
   // Leave it relative.
   if (!input_dir) input_dir = ".";
   if (!output_file)	output_file = "output.info";
-  std::string xsd_file_str;
   if (!xsd_file) {
     const char *ttcn3_dir = getenv("TTCN3_DIR");
     if (!ttcn3_dir) {
       std::cerr << "$TTCN3_DIR environment variable is not set" << std::endl;
       param_error = true;
     } else {
-      xsd_file_str = std::string(ttcn3_dir) + P_SEP + std::string("include") + P_SEP + std::string("tcov.xsd");
+      std::string xsd_file_str = std::string(ttcn3_dir) + P_SEP + std::string("include") + P_SEP + std::string("tcov.xsd");
       xsd_file = xsd_file_str.c_str();
     }
   }
diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc
index 70bb4e6417e4b9ce40bbe3fb33cb5d0b2a8866b0..1c37fdf5357ad33441dfdbc76d3271e718fd8699 100644
--- a/compiler2/ttcn3/AST_ttcn3.cc
+++ b/compiler2/ttcn3/AST_ttcn3.cc
@@ -4316,9 +4316,9 @@ namespace Ttcn {
     size_t min_fps = nof_base_fps;
     if (nof_local_fps < nof_base_fps) min_fps = nof_local_fps;
     for (size_t i = 0; i < min_fps; i++) {
-      FormalPar *base_fp = base_fpl->get_fp_byIndex(i);
       FormalPar *local_fp = fp_list->get_fp_byIndex(i);
       if (local_fp->has_notused_defval()) {
+        FormalPar *base_fp = base_fpl->get_fp_byIndex(i);
         if (base_fp->has_defval()) {
           local_fp->set_defval(base_fp->get_defval());
         } else {
@@ -8398,9 +8398,9 @@ namespace Ttcn {
       }
     }
 
-    Ttcn::Template * body = actual_par->get_Template();
     if (exp_val == Type::EXPECTED_STATIC_VALUE
       ||exp_val == Type::EXPECTED_CONSTANT) {
+      Ttcn::Template * body = actual_par->get_Template();
       chk_defpar_template(body, exp_val);
     }
     // Rip out the type, derived ref and template from actual_par
@@ -9949,7 +9949,6 @@ namespace Ttcn {
       if (copy_needed) FATAL_ERROR("ActualPar::generate_code()");
       bool is_restricted_template = gen_restriction_check != TR_NONE ||
         gen_post_restriction_check != TR_NONE;
-      Common::Assignment *ass = ref->get_refd_assignment();
       bool is_template_par = false;
       Type* actual_par_type = NULL;
       Type* formal_par_type = NULL;
@@ -9961,6 +9960,7 @@ namespace Ttcn {
             formal_par->get_asstype() == Common::Assignment::A_PAR_TEMPL_OUT) {
           is_template_par = true;
         }
+        Common::Assignment *ass = ref->get_refd_assignment();
         actual_par_type = ass->get_Type()->get_field_type(ref->get_subrefs(),
           is_template_par ? Type::EXPECTED_TEMPLATE : Type::EXPECTED_DYNAMIC_VALUE)->
           get_type_refd_last();
diff --git a/compiler2/ttcn3/Attributes.cc b/compiler2/ttcn3/Attributes.cc
index c291857c43e81d6ef3175b1faa42db7aadea6b53..eb37854586da5ab238f2b4c3a9063c18388d27bf 100644
--- a/compiler2/ttcn3/Attributes.cc
+++ b/compiler2/ttcn3/Attributes.cc
@@ -692,8 +692,6 @@ namespace Ttcn {
     map< size_t, dynamic_array<field_err_t> > embedded_fld_array_m; // used for recursive calls
     for (size_t i=0; i<fld_array.size(); i++) {
       field_err_t& act_field_err = fld_array[i];
-      ErroneousAttributeSpec::indicator_t act_indicator = act_field_err.err_attr->get_indicator();
-      bool is_omit = act_field_err.err_attr->get_is_omit();
       if (act_field_err.subrefs_array.size()<1) FATAL_ERROR("ErroneousAttributes::build_descr_tree()");
       size_t fld_idx = act_field_err.subrefs_array[0];
       if (omit_before_qual && (err_descr->omit_before!=-1) && (err_descr->omit_before>(int)fld_idx)) {
@@ -708,6 +706,8 @@ namespace Ttcn {
           act_field_err.qualifier->get_stringRepr().c_str(), omit_after_qual->get_stringRepr().c_str());
         continue;
       }
+      ErroneousAttributeSpec::indicator_t act_indicator = act_field_err.err_attr->get_indicator();
+      bool is_omit = act_field_err.err_attr->get_is_omit();
       if (act_field_err.subrefs_array.size()==1) { // erroneous value
         if (act_field_err.type_array.size()!=1) FATAL_ERROR("ErroneousAttributes::build_descr_tree()");
         if ((act_field_err.type_array[0]->get_typetype()==Type::T_SET_A) &&
diff --git a/compiler2/ttcn3/TextAST.cc b/compiler2/ttcn3/TextAST.cc
index c73db14c5939a5789cf25d14afe1388bc2cd33a7..21ef5ba5dd3831790e740e8258286d2f66dddeeb 100644
--- a/compiler2/ttcn3/TextAST.cc
+++ b/compiler2/ttcn3/TextAST.cc
@@ -431,7 +431,7 @@ char *make_posix_str_code(const char *pat, bool cs)
   Free(mod_token);
   if (posix_str == NULL) FATAL_ERROR("make_posix_str_code()");
 
-  size_t len = mstrlen(posix_str), skip = 0;
+  size_t len = mstrlen(posix_str);
   if (maybe_fixed) { // maybe we can do fixed strings
     *ret_val = 'F'; // "fixed"
 
@@ -439,6 +439,7 @@ char *make_posix_str_code(const char *pat, bool cs)
     ret_val = mputstrn(ret_val, posix_str + 2, len - 6);
   }
   else { // no fixed-string optimization possible
+    size_t skip = 0;
     // TEXT decoder optimization
     if (len > 3) {
       if (!memcmp(posix_str + (len - 3), ".*$", 3)) {
diff --git a/compiler2/ttcn3/TtcnTemplate.cc b/compiler2/ttcn3/TtcnTemplate.cc
index b07ec02032100e4290e7758b1f121e5edf97f2d2..5e86d6583ef4820d5e3b69c7b671afd09417671a 100644
--- a/compiler2/ttcn3/TtcnTemplate.cc
+++ b/compiler2/ttcn3/TtcnTemplate.cc
@@ -2767,9 +2767,9 @@ end:
     switch (templatetype) {
     case NAMED_TEMPLATE_LIST:
       for (size_t i = 0;i < u.named_templates->get_nof_nts(); i++) {
-        Template* tmpl = u.named_templates->get_nt_byIndex(i)->get_template();
-        const string& name =
-          u.named_templates->get_nt_byIndex(i)->get_name().get_name();
+        NamedTemplate *nt = u.named_templates->get_nt_byIndex(i);
+        Template* tmpl = nt->get_template();
+        const string& name = nt->get_name().get_name();
         if (!checked_map.has_key(name)) {
           bool nrc = tmpl->chk_restriction(definition_name, TR_OMIT, usage_loc);
           needs_runtime_check = needs_runtime_check || nrc;
@@ -4068,21 +4068,14 @@ compile_time:
 
   char *Template::generate_code_init_se(char *str, const char *name)
   { // named template list
-    size_t nof_nts = u.named_templates->get_nof_nts();
     Type *type = my_governor->get_type_refd_last();
     if (type->get_nof_comps() > 0) {
+      size_t nof_nts = u.named_templates->get_nof_nts();
       for (size_t i = 0; i < nof_nts; i++) {
         NamedTemplate *nt = u.named_templates->get_nt_byIndex(i);
         const Identifier& fieldname = nt->get_name();
-        const char *fieldname_str = 0;
-        string at("AT_");
-        if (type->get_typetype()==Type::T_ANYTYPE) {
-          at += fieldname.get_name();
-          fieldname_str = at.c_str();
-        }
-        else {
-          fieldname_str = fieldname.get_name().c_str();
-        }
+        const char *fieldname_str = mprintf("%s%s",
+              type->get_typetype()==Type::T_ANYTYPE ? "AT_" : "", fieldname.get_name().c_str());
         Template *t = nt->get_template();
         if (t->needs_temp_ref()) {
           Type *field_type;
diff --git a/core/Basetype.cc b/core/Basetype.cc
index c0f5ea63c8fc706c196c0af2b9fb12e61b9c04c8..eba72a6c2e21f481c6147f2e23419a35de46fe39 100644
--- a/core/Basetype.cc
+++ b/core/Basetype.cc
@@ -234,7 +234,6 @@ int Base_Type::begin_xml(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf,
   unsigned int& flavor, int indent, boolean empty,
   collector_fn collector, const char *type_atr, unsigned int flavor2) const
 {
-  const int indenting = !is_canonical(flavor);
   const int exer = is_exer(flavor);
   int omit_tag = (indent != 0) // can never omit the tag at the toplevel
     && ( ((flavor & XER_RECOF) // can remove the tag even if not EXER
@@ -243,24 +242,18 @@ int Base_Type::begin_xml(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf,
         && ( (p_td.xer_bits & (UNTAGGED|ANY_ATTRIBUTES|ANY_ELEMENT))
           || (flavor & (EMBED_VALUES|XER_LIST|ANY_ATTRIBUTES|USE_NIL|USE_TYPE_ATTR)))));
 
-  // If a default namespace is in effect (uri but no prefix) and the type
-  // is unqualified, the default namespace must be canceled; otherwise
-  // an XML tag without a ns prefix looks like it belongs to the def.namespace
-  const boolean empty_ns_hack = exer && !omit_tag && (indent > 0)
-    && (p_td.xer_bits & FORM_UNQUALIFIED)
-    && (flavor & DEF_NS_PRESENT);
-
   if (exer && (p_td.xer_bits & XER_ATTRIBUTE)) {
     begin_attribute(p_td, p_buf);
   }
   else if (!omit_tag) { // full tag
+    const int indenting = !is_canonical(flavor);
     if (indenting) do_indent(p_buf, indent);
     p_buf.put_c('<');
     if (exer) write_ns_prefix(p_td, p_buf);
 
-    const namespace_t *ns_info = NULL;
     boolean namespaces_needed = FALSE;
     if (exer) {
+      const namespace_t *ns_info = NULL;
       if (p_td.my_module != NULL && p_td.ns_index != -1) {
         ns_info = p_td.my_module->get_ns((size_t)p_td.ns_index);
       }
@@ -289,6 +282,13 @@ int Base_Type::begin_xml(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf,
       Free(collected_ns);
     }
 
+    // If a default namespace is in effect (uri but no prefix) and the type
+    // is unqualified, the default namespace must be canceled; otherwise
+    // an XML tag without a ns prefix looks like it belongs to the def.namespace
+    const boolean empty_ns_hack = exer && !omit_tag && (indent > 0)
+      && (p_td.xer_bits & FORM_UNQUALIFIED)
+      && (flavor & DEF_NS_PRESENT);
+
     if (empty_ns_hack) {
       p_buf.put_s(9, (cbyte*)" xmlns=''");
       flavor &= ~DEF_NS_PRESENT;
@@ -338,7 +338,6 @@ void Base_Type::end_xml  (const XERdescriptor_t& p_td, TTCN_Buffer& p_buf,
   unsigned int flavor, int indent, boolean empty) const
 {
   int exer = is_exer(flavor);
-  int indenting = !is_canonical(flavor);
   boolean omit_tag = (indent != 0) // can never omit the tag at the toplevel
     && ( ((flavor & XER_RECOF) // can remove the tag even if not EXER
       && !(exer && (flavor & BXER_EMPTY_ELEM))) // except 26.6, 26.7
@@ -351,6 +350,7 @@ void Base_Type::end_xml  (const XERdescriptor_t& p_td, TTCN_Buffer& p_buf,
   }
   else if (!empty && !omit_tag) {
     // now close the tag
+    int indenting = !is_canonical(flavor);
     if (indenting && !(flavor & SIMPLE_TYPE)) do_indent(p_buf, indent);
     p_buf.put_s(2, (cbyte*)"</");
     if (exer) write_ns_prefix(p_td, p_buf);
diff --git a/core/Charstring.cc b/core/Charstring.cc
index eeb4bce4f340e3b5074d69ad052c5165a243a4dd..71d898e165ea4cba32ece3fa61128f08299a4aa0 100644
--- a/core/Charstring.cc
+++ b/core/Charstring.cc
@@ -1356,7 +1356,6 @@ unsigned int xlate(cbyte*in, int phase, unsigned char*dest) {
 int CHARSTRING::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
                            unsigned int flavor, unsigned int /*flavor2*/, embed_values_dec_struct_t*) {
   int exer = is_exer(flavor);
-  int success = reader.Ok(), depth = -1;
 
   if (exer && (p_td.xer_bits & XER_ATTRIBUTE)) {
     const char * name = verify_name(reader, p_td, exer);
@@ -1370,6 +1369,7 @@ int CHARSTRING::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
   else {
     boolean omit_tag = exer
       && (p_td.xer_bits & UNTAGGED || flavor & (EMBED_VALUES|XER_LIST|USE_TYPE_ATTR|USE_NIL));
+    int success = reader.Ok(), depth = -1;
     for (; success == 1; success = reader.Read()) {
       int type = reader.NodeType();
       if (XML_READER_TYPE_ELEMENT == type) {
diff --git a/core/Float.cc b/core/Float.cc
index 9aaa02768da58c5587e0f47794cbf0562cdbc69a..92121c9811909dadc63a4f376c035559fc0c0e12 100644
--- a/core/Float.cc
+++ b/core/Float.cc
@@ -750,7 +750,6 @@ int FLOAT::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& buff,
   boolean /*first_call*/)
 {
   int prepaddlength = buff.increase_pos_padd(p_td.raw->prepadding);
-  unsigned char *dv;
   limit -= prepaddlength;
   int decode_length = p_td.raw->fieldlength;
   if ( p_td.raw->fieldlength > limit
@@ -780,7 +779,7 @@ int FLOAT::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& buff,
   cp.hexorder = ORDER_LSB;
   buff.get_b((size_t) decode_length, data, cp, top_bit_ord);
   if (decode_length == 64) {
-    dv = (unsigned char *) &tmp;
+    unsigned char *dv = (unsigned char *) &tmp;
 #if defined __sparc__ || defined __sparc
     memcpy(dv,data,8);
 #else
diff --git a/core/Hexstring.cc b/core/Hexstring.cc
index 3901709311b65048f9efe0a17456a19fc82907c4..4242a016270a46a1cb7711e84687a53a53066aab 100644
--- a/core/Hexstring.cc
+++ b/core/Hexstring.cc
@@ -930,7 +930,6 @@ int HEXSTRING::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
   int success = reader.Ok(), depth = -1, type;
   boolean own_tag = !is_exerlist(flavor) && !(exer && (p_td.xer_bits & UNTAGGED));
 
-  const char * value = 0;
   if (exer && (p_td.xer_bits & XER_ATTRIBUTE)) {
     const char * name = verify_name(reader, p_td, exer);
     (void)name;
@@ -970,7 +969,7 @@ int HEXSTRING::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
 
   type = reader.NodeType();
   if (success == 1 && (XML_READER_TYPE_TEXT == type || XML_READER_TYPE_ATTRIBUTE == type)) {
-    value = (const char *)reader.Value();
+    const char * value = (const char *)reader.Value();
     size_t len = value ? strlen(value) : 0;
 
     if (exer && (p_td.xer_bits & BASE_64)) {
diff --git a/core/Integer.cc b/core/Integer.cc
index 9f937592b6f73031860bf0f5f866683f1e54a98c..82157f0c8ee1bd38f1578f7c63bc8cbda788147b 100644
--- a/core/Integer.cc
+++ b/core/Integer.cc
@@ -276,11 +276,11 @@ INTEGER INTEGER::operator+(const INTEGER& other_value) const
     : BN_is_negative(val.openssl);
   boolean other_value_neg = other_value.native_flag
     ? (other_value.val.native < 0) : BN_is_negative(other_value.val.openssl);
-  boolean result_neg = this_neg && other_value_neg;
   if (!this_neg && other_value_neg) return operator-(-other_value);
   if (this_neg && !other_value_neg) return other_value.operator-(-(*this));
   if (likely(native_flag)) {
     if (likely(other_value.native_flag)) {
+      boolean result_neg = this_neg && other_value_neg;
       unsigned int result_u = val.native + other_value.val.native;
       int result = val.native + other_value.val.native;
       if ((static_cast<int>(result_u) != result) || (!result_neg &&
@@ -1625,7 +1625,6 @@ int INTEGER::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
   unsigned int flavor, unsigned int /*flavor2*/, embed_values_dec_struct_t*)
 {
   const boolean exer = is_exer(flavor);
-  int depth = -1, success = reader.Ok(), type;
   const char * value = 0;
 
   boolean own_tag = !(exer && (p_td.xer_bits & UNTAGGED)) && !is_exerlist(flavor);
@@ -1644,6 +1643,7 @@ tagless:
     // Let the caller do reader.AdvanceAttribute();
   }
   else {
+    int depth = -1, success = reader.Ok(), type;
     for (; success == 1; success = reader.Read()) {
       type = reader.NodeType();
       if (XML_READER_TYPE_ELEMENT == type) {
diff --git a/core/Octetstring.cc b/core/Octetstring.cc
index 64174796782e8df0caa5db8977ef073c342676cd..1a757f3798fb68da65b576c0aeed66947184d384 100644
--- a/core/Octetstring.cc
+++ b/core/Octetstring.cc
@@ -968,7 +968,6 @@ int OCTETSTRING::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
   int success = reader.Ok(), depth = -1, type;
   boolean own_tag = !is_exerlist(flavor) && !(exer && (p_td.xer_bits & UNTAGGED));
 
-  const char * value = 0;
   if (exer && (p_td.xer_bits & XER_ATTRIBUTE)) {
     const char * name = verify_name(reader, p_td, exer);
     (void)name;
@@ -1008,7 +1007,7 @@ int OCTETSTRING::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
 
   type = reader.NodeType();
   if (success == 1 && (XML_READER_TYPE_TEXT == type || XML_READER_TYPE_ATTRIBUTE == type)) {
-    value = (const char *)reader.Value();
+    const char * value = (const char *)reader.Value();
     size_t len = value ? strlen(value) : 0;
 
     if (exer && (p_td.xer_bits & BASE_64)) {
diff --git a/core/Profiler.cc b/core/Profiler.cc
index 2c5bd0a5aff8f1c8c399b2c1cdb9c47bf2539d1d..abfdd0808edb308a6b5a9ed9c6396dcb8d9935d7 100644
--- a/core/Profiler.cc
+++ b/core/Profiler.cc
@@ -273,10 +273,9 @@ void TTCN3_Profiler::enter_function(const char* filename, int lineno)
   execute_line(filename, lineno);
   
   if (!stopped) {
-    unsigned int element = get_element(filename);
-
     // store function data
     if (!disable_coverage) {
+      unsigned int element = get_element(filename);
       ++profiler_db[element].functions[get_function(element, lineno)].exec_count;
     }
   }
diff --git a/core/Verdicttype.cc b/core/Verdicttype.cc
index 133ebd945c83b7e82efd9f2a75e59ba725864664..03d9e544f60f88c16e777adeebc36a673f646b1e 100644
--- a/core/Verdicttype.cc
+++ b/core/Verdicttype.cc
@@ -319,9 +319,7 @@ verdicttype VERDICTTYPE::str_to_verdict(const char *v, boolean silent)
 int VERDICTTYPE::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& p_reader,
   unsigned int p_flavor, unsigned int /*flavor2*/, embed_values_dec_struct_t*)
 {
-  int rd_ok = 1, type;
   const boolean e_xer = is_exer(p_flavor);
-  const boolean name_tag = !((!e_xer && is_record_of(p_flavor)) || (e_xer && ((p_td.xer_bits & UNTAGGED) ||(is_record_of(p_flavor) && is_exerlist(p_flavor)))));
   if (e_xer && ((p_td.xer_bits & XER_ATTRIBUTE) || is_exerlist(p_flavor))) {
     if ((p_td.xer_bits & XER_ATTRIBUTE)) verify_name(p_reader, p_td, e_xer);
     const char * value = (const char *)p_reader.Value();
@@ -330,7 +328,10 @@ int VERDICTTYPE::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& p_reader
     }
   }
   else {
-    if (name_tag)      for (; rd_ok == 1; rd_ok = p_reader.Read()) {
+    int rd_ok = 1, type;
+    const boolean name_tag = !((!e_xer && is_record_of(p_flavor)) || (e_xer && ((p_td.xer_bits & UNTAGGED) ||(is_record_of(p_flavor) && is_exerlist(p_flavor)))));
+    if (name_tag)
+      for (; rd_ok == 1; rd_ok = p_reader.Read()) {
         type = p_reader.NodeType();
         if (XML_READER_TYPE_ELEMENT == type) {
           // If our parent is optional and there is an unexpected tag then return and
diff --git a/core/XmlReader.cc b/core/XmlReader.cc
index 39ca6d210c9d76f3cf716b73346d1ea411ecffdd..294001b3b928ffec5cc50edc7220c2d3f1f94083 100644
--- a/core/XmlReader.cc
+++ b/core/XmlReader.cc
@@ -74,12 +74,12 @@ XmlReaderWrap::XmlReaderWrap(TTCN_Buffer& buf)
     xmlreader_lite::XML_READER_TYPE_XML_DECLARATION);
 
   LIBXML_TEST_VERSION;
-  const char * encoding = 0;
   if (0 == buf.get_len()) {
     TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INCOMPL_MSG,
       "Cannot decode empty XML");
   }
   else {
+    const char * encoding = 0;
     my_reader = xmlReaderForMemory((const char*)buf.get_data(), buf.get_len(),
       "uri:geller", encoding, 0);
     if (0 == my_reader) {
diff --git a/core/simplify.pl b/core/simplify.pl
old mode 100755
new mode 100644
diff --git a/xsdconvert/ComplexType.cc b/xsdconvert/ComplexType.cc
index 7d55688b95a8ca29b6692fe3d9e6cd58243c819b..ffc27638894e6330f184fc90cb2d4ff388747148 100644
--- a/xsdconvert/ComplexType.cc
+++ b/xsdconvert/ComplexType.cc
@@ -562,8 +562,8 @@ void ComplexType::loadWithValues() {
     {
       xsdtype = parser->getActualTagName();
       cmode = CT_simpletype_mode;
-      Mstring fieldname;
       if (with_union && hasVariant(Mstring("useUnion"))) {
+        Mstring fieldname;
         if (max_alt == 0) {
           fieldname = Mstring("alt_");
         } else {