diff --git a/compiler2/ttcn3/Statement.cc b/compiler2/ttcn3/Statement.cc
index cb87d8ee455cfe4876a6c57d3c6bdad97b09ce42..863cab0512cb5f6be4abff577b571d81d85022df 100644
--- a/compiler2/ttcn3/Statement.cc
+++ b/compiler2/ttcn3/Statement.cc
@@ -3579,7 +3579,7 @@ error:
   {
     Error_Context cntxt(this, "In send statement");
     // checking the port reference
-    Type *port_type;
+    Type *port_type = NULL;
     if (port_op.translate) {
       PortScope* ps = my_sb->get_scope_port();
       if (ps) {
@@ -3973,7 +3973,7 @@ error:
     const char *stmt_name = get_stmt_name();
     Error_Context cntxt(this, "In %s statement", stmt_name);
     // checking the port reference
-    Type *port_type;
+    Type *port_type = NULL;
     if (port_op.translate) {
       PortScope* ps = my_sb->get_scope_port();
       if (ps) {
diff --git a/core/OER.hh b/core/OER.hh
index ccf29fb6481c0ee9d3a93a5d8b61e66fefcb08ea..5267760e7cc508ce4e53a35d809b6b564aaf2eb7 100644
--- a/core/OER.hh
+++ b/core/OER.hh
@@ -16,8 +16,8 @@
 #include "Vector.hh"
 
 class TTCN_Buffer;
-class ASN_BERdescriptor_t;
-class ASN_Tag_t;
+struct ASN_BERdescriptor_t;
+struct ASN_Tag_t;
 
 struct TTCN_OERdescriptor_t 
 {
diff --git a/core/Template.cc b/core/Template.cc
index cde7b979387452150ef71eb177a80fba8d5d8968..5c990d7739838648dac65d6dd043d5987b069a96 100644
--- a/core/Template.cc
+++ b/core/Template.cc
@@ -2838,12 +2838,12 @@ Base_Template* Record_Template::get_at(int index_value)
 
 const Base_Template* Record_Template::get_at(int index_value) const
 {
-  if (index_value < 0 || index_value >= single_value.n_elements)
-    TTCN_error("Internal error: accessing an element of a template of type %s using an "
-      "invalid index: %d.", get_descriptor()->name, index_value);
   if (template_selection != SPECIFIC_VALUE)
     TTCN_error("Accessing field %s of a non-specific template of type %s.",
                fld_name(index_value), get_descriptor()->name);
+  if (index_value < 0 || index_value >= single_value.n_elements)
+    TTCN_error("Internal error: accessing an element of a template of type %s using an "
+      "invalid index: %d.", get_descriptor()->name, index_value);
   return single_value.value_elements[index_value];
 }