diff --git a/common/ModuleVersion.cc b/common/ModuleVersion.cc
index 3dc5511ed9da927a0e0f02f80b97bb35a2644301..aff2b22f93fcb18d42f085c29fe846f43fb2fc72 100644
--- a/common/ModuleVersion.cc
+++ b/common/ModuleVersion.cc
@@ -29,7 +29,7 @@ std::string ModuleVersion::toString() const {
   }
   if (release != 0) {
     stream << separator << 'R' << release << separator
-      << (char)('A' + patch);
+      << static_cast<char>('A' + patch);
   }
   if (build != 0) {
     stream << separator << build;
diff --git a/common/NetworkHandler.cc b/common/NetworkHandler.cc
index afa18be0c442013e8acfd5664f42e4f38f86c688..a361b8d538e091f339d4681f7b9cd13c9efe8913 100644
--- a/common/NetworkHandler.cc
+++ b/common/NetworkHandler.cc
@@ -188,11 +188,11 @@ bool IPv4Address::set_addr(const char *p_addr, unsigned short p_port)
   clean_up();
   if (p_addr != NULL) {
     struct hostent *hptr = gethostbyname(p_addr);
-    if (hptr != NULL && (size_t)hptr->h_length == sizeof(struct in_addr)) {
+    if (hptr != NULL && static_cast<size_t>(hptr->h_length) == sizeof(struct in_addr)) {
       m_addr.sin_family = AF_INET;
       m_addr.sin_port = htons(p_port);
       memset(m_addr.sin_zero, 0, sizeof(m_addr.sin_zero));
-      memcpy(&m_addr.sin_addr, hptr->h_addr_list[0], hptr->h_length);
+      memcpy(&m_addr.sin_addr, hptr->h_addr_list[0], static_cast<size_t>(hptr->h_length));
       strncpy(m_addr_str, inet_ntoa(m_addr.sin_addr), sizeof(m_addr_str));
       strncpy(m_host_str, hptr->h_name, sizeof(m_host_str));
       return true;
@@ -212,7 +212,7 @@ int IPv4Address::accept(int p_sockfd)
       struct hostent *hptr =
         gethostbyaddr((const char *)&m_addr.sin_addr,
                       sizeof(m_addr.sin_addr), m_addr.sin_family);
-      if (hptr != NULL && (size_t)hptr->h_length == sizeof(struct in_addr)) {
+      if (hptr != NULL && static_cast<size_t>(hptr->h_length) == sizeof(struct in_addr)) {
         strncpy(m_host_str, hptr->h_name, sizeof(m_host_str));
       }
     }
@@ -231,7 +231,7 @@ int IPv4Address::getsockname(int p_sockfd)
       struct hostent *hptr =
         gethostbyaddr((const char *)&m_addr.sin_addr,
                       sizeof(m_addr.sin_addr), m_addr.sin_family);
-      if (hptr != NULL && (size_t)hptr->h_length == sizeof(struct in_addr)) {
+      if (hptr != NULL && static_cast<size_t>(hptr->h_length) == sizeof(struct in_addr)) {
         strncpy(m_host_str, hptr->h_name, sizeof(m_host_str));
       }
     }
@@ -241,7 +241,7 @@ int IPv4Address::getsockname(int p_sockfd)
 
 bool IPv4Address::operator==(const IPAddress& p_addr) const
 {
-  return memcmp(&m_addr.sin_addr, &(((const IPv4Address&)p_addr).m_addr.sin_addr), sizeof(m_addr.sin_addr)) == 0;
+  return memcmp(&m_addr.sin_addr, &((static_cast<const IPv4Address&>(p_addr)).m_addr.sin_addr), sizeof(m_addr.sin_addr)) == 0;
 }
 
 bool IPv4Address::operator!=(const IPAddress& p_addr) const
@@ -252,9 +252,9 @@ bool IPv4Address::operator!=(const IPAddress& p_addr) const
 IPAddress& IPv4Address::operator=(const IPAddress& p_addr)
 {
   clean_up();
-  memcpy(&m_addr, &((const IPv4Address&)p_addr).m_addr, sizeof(m_addr));
-  strncpy(m_host_str, ((const IPv4Address&)p_addr).m_host_str, sizeof(m_host_str));
-  strncpy(m_addr_str, ((const IPv4Address&)p_addr).m_addr_str, sizeof(m_addr_str));
+  memcpy(&m_addr, &(static_cast<const IPv4Address&>(p_addr)).m_addr, sizeof(m_addr));
+  strncpy(m_host_str, (static_cast<const IPv4Address&>(p_addr)).m_host_str, sizeof(m_host_str));
+  strncpy(m_addr_str, (static_cast<const IPv4Address&>(p_addr)).m_addr_str, sizeof(m_addr_str));
   return *this;
 }
 
@@ -325,7 +325,7 @@ bool IPv6Address::set_addr(const char *p_addr, unsigned short p_port)
   snprintf(p_port_str, sizeof(p_port_str), "%u", p_port);
   int s = getaddrinfo(p_addr, p_port_str, &hints, &res);
   if (s == 0) {
-    struct sockaddr_in6 *addr = (struct sockaddr_in6 *)(void*)res->ai_addr;
+    struct sockaddr_in6 *addr = static_cast<struct sockaddr_in6 *>(static_cast<void*>(res->ai_addr));
     // The (void*) shuts up the "cast increases required alignment" warning.
     // Hopefully, the res->ai_addr points to a properly aligned sockaddr_in6
     // and we won't have problems like these if we decide to support Sparc:
@@ -382,7 +382,7 @@ int IPv6Address::getsockname(int p_sockfd)
 
 bool IPv6Address::operator==(const IPAddress& p_addr) const
 {
-  return memcmp(&m_addr.sin6_addr, &(((const IPv6Address&)p_addr).m_addr.sin6_addr), sizeof(m_addr.sin6_addr)) == 0;
+  return memcmp(&m_addr.sin6_addr, &((static_cast<const IPv6Address&>(p_addr)).m_addr.sin6_addr), sizeof(m_addr.sin6_addr)) == 0;
 }
 
 bool IPv6Address::operator!=(const IPAddress& p_addr) const
@@ -393,9 +393,9 @@ bool IPv6Address::operator!=(const IPAddress& p_addr) const
 IPAddress& IPv6Address::operator=(const IPAddress& p_addr)
 {
   clean_up();
-  memcpy(&m_addr, &((const IPv6Address&)p_addr).m_addr, sizeof(m_addr));
-  strncpy(m_host_str, ((const IPv6Address&)p_addr).m_host_str, sizeof(m_host_str));
-  strncpy(m_addr_str, ((const IPv6Address&)p_addr).m_addr_str, sizeof(m_addr_str));
+  memcpy(&m_addr, &(static_cast<const IPv6Address&>(p_addr)).m_addr, sizeof(m_addr));
+  strncpy(m_host_str, (static_cast<const IPv6Address&>(p_addr)).m_host_str, sizeof(m_host_str));
+  strncpy(m_addr_str, (static_cast<const IPv6Address&>(p_addr)).m_addr_str, sizeof(m_addr_str));
   return *this;
 }
 
diff --git a/common/Quadruple.cc b/common/Quadruple.cc
index c2537a93cf23cbed4de23bedaafd064f1ddd4b90..3e019f5460f950b4c15f80cc1d53b518df2bfd8a 100644
--- a/common/Quadruple.cc
+++ b/common/Quadruple.cc
@@ -66,10 +66,10 @@ void Quad::set(unsigned char group, unsigned char plane, unsigned char row,
 }
 
 void Quad::set_hexrepr(const char* hex_repr) {
-  u.comp.group = (unsigned char)(((hex_repr[0] - 'A') << 4) + (hex_repr[1] - 'A'));
-  u.comp.plane = (unsigned char)(((hex_repr[2] - 'A') << 4) + (hex_repr[3] - 'A'));
-  u.comp.row =   (unsigned char)(((hex_repr[4] - 'A') << 4) + (hex_repr[5] - 'A'));
-  u.comp.cell =  (unsigned char)(((hex_repr[6] - 'A') << 4) + (hex_repr[7] - 'A'));
+  u.comp.group = static_cast<unsigned char>(((hex_repr[0] - 'A') << 4) + (hex_repr[1] - 'A'));
+  u.comp.plane = static_cast<unsigned char>(((hex_repr[2] - 'A') << 4) + (hex_repr[3] - 'A'));
+  u.comp.row =   static_cast<unsigned char>(((hex_repr[4] - 'A') << 4) + (hex_repr[5] - 'A'));
+  u.comp.cell =  static_cast<unsigned char>(((hex_repr[6] - 'A') << 4) + (hex_repr[7] - 'A'));
 }
 
 const Quad Quad::operator-(const Quad& rhs) const {
@@ -133,21 +133,21 @@ char* Quad::get_hexrepr(unsigned int value) {
 }
 
 void Quad::get_hexrepr(const Quad& q, char* const str) {
-  str[0] = (char)('A' + (q.u.comp.group >> 4)); // high end
-  str[1] = (char)('A' + (q.u.comp.group & 15));
-  str[2] = (char)('A' + (q.u.comp.plane >> 4));
-  str[3] = (char)('A' + (q.u.comp.plane & 15));
-  str[4] = (char)('A' + (q.u.comp.row   >> 4));
-  str[5] = (char)('A' + (q.u.comp.row   & 15));
-  str[6] = (char)('A' + (q.u.comp.cell  >> 4));
-  str[7] = (char)('A' + (q.u.comp.cell  & 15)); // low end
+  str[0] = static_cast<char>('A' + (q.u.comp.group >> 4)); // high end
+  str[1] = static_cast<char>('A' + (q.u.comp.group & 15));
+  str[2] = static_cast<char>('A' + (q.u.comp.plane >> 4));
+  str[3] = static_cast<char>('A' + (q.u.comp.plane & 15));
+  str[4] = static_cast<char>('A' + (q.u.comp.row   >> 4));
+  str[5] = static_cast<char>('A' + (q.u.comp.row   & 15));
+  str[6] = static_cast<char>('A' + (q.u.comp.cell  >> 4));
+  str[7] = static_cast<char>('A' + (q.u.comp.cell  & 15)); // low end
 }
 
 char* Quad::char_hexrepr(unsigned char c) {
   char hex[3];
   hex[2] = '\0';
-  hex[1] = (char)((c & 15) + 'A');
-  hex[0] = (char)((c >> 4) + 'A');
+  hex[1] = static_cast<char>((c & 15) + 'A');
+  hex[0] = static_cast<char>((c >> 4) + 'A');
   return mcopystr(hex);
 }
 
@@ -235,7 +235,7 @@ char* QuadInterval::generate_posix() {
                 Free(str);
                 q1.set(j, 0);
                 if (j > 0 && q1[j-1] < 255)
-                  q1.set(j - 1, (unsigned char)(q1[j-1] + 1));
+                  q1.set(j - 1, static_cast<unsigned char>(q1[j-1] + 1));
                 for (k = j + 1; k < 4; k++) {
                   res = mputprintf(res, "%s",
                     str = generate_hex_interval(0, 255));
@@ -251,8 +251,8 @@ char* QuadInterval::generate_posix() {
               res = mputstr(res, str = Quad::char_hexrepr(lower[j]));
               Free(str);
             }
-            str = generate_hex_interval((unsigned char)(lower[c] + 1),
-              (unsigned char)(lower[c] + diff[c] - 1));
+            str = generate_hex_interval(static_cast<unsigned char>(lower[c] + 1),
+              static_cast<unsigned char>(lower[c] + diff[c] - 1));
             res = mputprintf(res, "%s", str);
             Free(str);
             k = (3 - c) * 2;
@@ -274,7 +274,7 @@ char* QuadInterval::generate_posix() {
               }
               c++;
               if (c < 3)
-                q2.set(c, (unsigned char)(upper[c] - 1));
+                q2.set(c, static_cast<unsigned char>(upper[c] - 1));
               res = mputstr(res, str = generate_hex_interval(q1[c], q2[c]));
               Free(str);
               for (j = c + 1; j < 4; j++) {
@@ -328,14 +328,14 @@ char* QuadInterval::generate_hex_interval(unsigned char source,
     if (lo < 0) { // This is possibly reported during parsing.
       TTCN_pattern_error("Illegal interval in set: start > end.");
     } else if (lo > 0) {
-      res = mputc(res, (char)s_hi);
+      res = mputc(res, static_cast<char>(s_hi));
       if (s_lo == 'A' && d_lo == 'P')
         res = mputc(res, '.');
       else
         res = mputprintf(res, "[%c-%c]", s_lo, d_lo);
     } else {
-      res = mputc(res, (char)s_hi);
-      res = mputc(res, (char)s_lo);
+      res = mputc(res, static_cast<char>(s_hi));
+      res = mputc(res, static_cast<char>(s_lo));
     }
     return res;
   }
diff --git a/common/config_preproc.cc b/common/config_preproc.cc
index 4f0ab238ddf58ac1bc28cf173e47048f52c635e1..40e21703f103cd4c70671e03e492b63f3dd21fb0 100644
--- a/common/config_preproc.cc
+++ b/common/config_preproc.cc
@@ -32,7 +32,7 @@ void string_chain_add(string_chain_t **ec, char *s)
       i = i->next;
     }
   }
-  new_ec = (string_chain_t*) Malloc(sizeof(*new_ec));
+  new_ec = static_cast<string_chain_t*>( Malloc(sizeof(*new_ec)));
   new_ec->str = s;
   new_ec->next = NULL;
   if (i != NULL) i->next = new_ec;
@@ -85,11 +85,10 @@ const char* string_map_add(string_map_t *map, char *key,
   } else {
     /* creating a new entry */
     map->n++;
-    map->data = (string_keyvalue_t**)
-      Realloc(map->data, (map->n) * sizeof(*map->data));
+    map->data = static_cast<string_keyvalue_t**>(Realloc(map->data, (map->n) * sizeof(*map->data)));
     memmove(map->data + pos + 1, map->data + pos,
             (map->n - pos - 1) * sizeof(*map->data));
-    map->data[pos] = (string_keyvalue_t*)Malloc(sizeof(**map->data));
+    map->data[pos] = static_cast<string_keyvalue_t*>(Malloc(sizeof(**map->data)));
     map->data[pos]->key = key;
     map->data[pos]->value = value;
     map->data[pos]->value_len = value_len;
@@ -118,7 +117,7 @@ const char* string_map_get_bykey(const string_map_t *map,
 
 string_map_t* string_map_new(void)
 {
-  string_map_t *map=(string_map_t*)Malloc(sizeof(string_map_t));
+  string_map_t *map = static_cast<string_map_t*>(Malloc(sizeof(string_map_t)));
   map->n=0;
   map->data=NULL;
   return map;
diff --git a/common/memory.h b/common/memory.h
index e4815d933c7cd9e6a0d5f3067e959dccf9f5eec4..55c0066ea7fed301fb2c593af9c290c5487efb29 100644
--- a/common/memory.h
+++ b/common/memory.h
@@ -287,9 +287,9 @@ extern "C" {
 #ifdef __cplusplus
   /** Convert a patch level to the "Ericsson letter" */
   inline char eri(unsigned int p) { /* p stands for patch level */
-    char   i = (char)('A' + p); /* i stands for "if only it was that simple" */
+    char   i = static_cast<char>('A' + p); /* i stands for "if only it was that simple" */
     const int result = i + (i >= 'I') + 4 * (i >= 'N') + (i >= 'R');
-    return (char)result; /*check: does not overflow*/
+    return static_cast<char>(result); /*check: does not overflow*/
   }
 
 } /* extern "C" */
diff --git a/common/new.cc b/common/new.cc
index 5ceac373826fb8c6868e75b549c0914aefa6901a..416ebb1bbfe45eebc4f07cd26cf0728e0a6b4e11 100644
--- a/common/new.cc
+++ b/common/new.cc
@@ -36,7 +36,7 @@ void operator delete(void *ptr) throw()
 
 void operator delete[](void *ptr) throw()
 {
-    if (ptr != (void*)&dummy) Free(ptr);
+    if (ptr != static_cast<void*>(&dummy)) Free(ptr);
 }
 
 /**************************************************************************/
diff --git a/common/pattern_la.l b/common/pattern_la.l
index 70f6586f621adef2201a0db7bbf63c076842b43a..be381a85440333989dc9511cdb0e4bc1e58c3cf1 100644
--- a/common/pattern_la.l
+++ b/common/pattern_la.l
@@ -213,12 +213,12 @@ NUMBER 0|([1-9][0-9]*)
 
  /* invalid escape sequences */
 "\\"(.|"\n") {
-  if (isprint((unsigned char)yytext[1]))
+  if (isprint(static_cast<unsigned char>(yytext[1])))
     TTCN_pattern_warning("Use of unrecognized escape sequence `\\%c' is "
       "deprecated.", yytext[1]);
   else TTCN_pattern_warning("Use of unrecognized escape sequence `\\' + "
-    "character code %u (0x%02X) is deprecated.", (unsigned char)yytext[1],
-    (unsigned char)yytext[1]);
+    "character code %u (0x%02X) is deprecated.", static_cast<unsigned char>(yytext[1]),
+    static_cast<unsigned char>(yytext[1]));
   yylval.c = yytext[1];
   return TOK_Char;
 }
@@ -239,30 +239,30 @@ NUMBER 0|([1-9][0-9]*)
  /* erroneous characters */
 
 <SC_Hash>.|\n {
-  if (isprint((unsigned char)yytext[0]))
+  if (isprint(static_cast<unsigned char>(yytext[0])))
     TTCN_pattern_error("A digit or `(' was expected after `#' instead of "
       "character `%c'.", yytext[0]);
   else TTCN_pattern_error("A digit or `(' was expected after `#' instead of "
-    "character with code %u (0x%02X).", (unsigned char)yytext[0],
-    (unsigned char)yytext[0]);
+    "character with code %u (0x%02X).", static_cast<unsigned char>(yytext[0]),
+    static_cast<unsigned char>(yytext[0]));
 }
 
 <SC_HashParen>. {
-  if (isprint((unsigned char)yytext[0]))
+  if (isprint(static_cast<unsigned char>(yytext[0])))
     TTCN_pattern_error("A number, `,' or `)' was expected after `#(' instead "
       "of character `%c'.", yytext[0]);
   else TTCN_pattern_error("A number, `,' or `)' was expected after `#(' "
-    "instead of character with code %u (0x%02X).", (unsigned char)yytext[0],
-    (unsigned char)yytext[0]);
+    "instead of character with code %u (0x%02X).", static_cast<unsigned char>(yytext[0]),
+    static_cast<unsigned char>(yytext[0]));
 }
 
 <SC_Quadruple,SC_Quadruple_Set>. {
-  if (isprint((unsigned char)yytext[0]))
+  if (isprint(static_cast<unsigned char>(yytext[0])))
     TTCN_pattern_error("A number, `,' or `}' was expected after `\\q{' "
       "instead of character `%c'.", yytext[0]);
   else TTCN_pattern_error("A number, `,' or `}' was expected after `\\q{' "
-    "instead of character with code %u (0x%02X).", (unsigned char)yytext[0],
-    (unsigned char)yytext[0]);
+    "instead of character with code %u (0x%02X).", static_cast<unsigned char>(yytext[0]),
+    static_cast<unsigned char>(yytext[0]));
 }
 
 %%
diff --git a/common/pattern_p.y b/common/pattern_p.y
index d09c03e0e3a8d4523ea7623984b023cdab86d9ff..2387760c2afb8209324232750a763b606b7b146d 100644
--- a/common/pattern_p.y
+++ b/common/pattern_p.y
@@ -489,7 +489,7 @@ RE_Set:
     if (']' > $3) {
       TTCN_pattern_error("Invalid range `%s' in the character set: the "
 	"character code of the lower bound (%u) is higher than that of the "
-	"upper bound (%u).", range_str, ']', (unsigned char)$3);
+	"upper bound (%u).", range_str, ']', static_cast<unsigned char>($3));
     } else {
       if (set_has_range($$, ']', $3)) {
 	character_set *tmpset = set_init();
@@ -550,7 +550,7 @@ RE_Set_Elem:
       char *range_str = print_range($1, $3);
       TTCN_pattern_error("Invalid range `%s' in the character set: the "
 	"character code of the lower bound (%u) is higher than that of the "
-	"upper bound (%u).", range_str, (unsigned char)$1, (unsigned char)$3);
+	"upper bound (%u).", range_str, static_cast<unsigned char>($1), static_cast<unsigned char>($3));
       Free(range_str);
     }
     $$ = set_init();
@@ -715,8 +715,8 @@ char *print_character(char c)
   case '\r':
     return mcopystr("\\r");
   default:
-    if (isprint((unsigned char)c)) return mprintf("%c", c);
-    else return mprintf("\\q{0,0,0,%u}", (unsigned char)c);
+    if (isprint(static_cast<unsigned char>(c))) return mprintf("%c", c);
+    else return mprintf("\\q{0,0,0,%u}", static_cast<unsigned char>(c));
   }
 }
 
@@ -739,14 +739,14 @@ struct character_set {
 
 character_set *set_init()
 {
-  character_set *set = (character_set*)Malloc(sizeof(*set));
+  character_set *set = static_cast<character_set*>(Malloc(sizeof(*set)));
   memset(set->set_members, 0, sizeof(set->set_members));
   return set;
 }
 
 character_set *set_copy(const character_set *set)
 {
-  character_set *set2 = (character_set*)Malloc(sizeof(*set2));
+  character_set *set2 = static_cast<character_set*>(Malloc(sizeof(*set2)));
   memcpy(set2, set, sizeof(*set2));
   return set2;
 }
@@ -791,7 +791,7 @@ void set_remove_char(character_set *set, char c)
 
 int set_has_range(const character_set *set, char lower, char upper)
 {
-  for (size_t i = lower; i <= (unsigned char)upper; i++)
+  for (size_t i = lower; i <= static_cast<unsigned char>(upper); i++)
     if (set->set_members[i / CS_BITS_PER_ELEM] & 1UL << i % CS_BITS_PER_ELEM)
       return 1;
   return 0;
@@ -799,7 +799,7 @@ int set_has_range(const character_set *set, char lower, char upper)
 
 void set_add_range(character_set *set, char lower, char upper)
 {
-  for (size_t i = lower; i <= (unsigned char)upper; i++)
+  for (size_t i = lower; i <= static_cast<unsigned char>(upper); i++)
     set->set_members[i / CS_BITS_PER_ELEM] |= 1UL << i % CS_BITS_PER_ELEM;
 }
 
diff --git a/common/pattern_uni.y b/common/pattern_uni.y
index c981cc9899f885dec2ea7916097c3a18cb35a1a0..e2a8e5967971ce31b195dc28de82095b85df5816 100644
--- a/common/pattern_uni.y
+++ b/common/pattern_uni.y
@@ -449,10 +449,10 @@ RE_Set:
       $$ = $4;
     else
       $$ = new QuadSet();
-    if ((unsigned int)']' > $3.value) {
+    if (static_cast<unsigned int>(']') > $3.value) {
       TTCN_pattern_error("Invalid range in the character set: the "
         "character code of the lower bound (%u) is higher than that of the "
-        "upper bound (%u).", ']', (unsigned int)$3.value);
+        "upper bound (%u).", ']', static_cast<unsigned int>($3.value));
     }
     $$->add(new QuadInterval(Quad(']'), Quad($3.value)));
     if ($5) {
@@ -504,7 +504,7 @@ RE_Set_Elem:
     if ($1.value > $3.value) {
       TTCN_pattern_error("Invalid range in the character set: the "
         "character code of the lower bound (%u) is higher than that of the "
-        "upper bound (%u).", (unsigned int)$1.value, (unsigned int)$3.value);
+        "upper bound (%u).", static_cast<unsigned int>($1.value), static_cast<unsigned int>($3.value));
     }
     $$ = new QuadSet();
     $$->add(new QuadInterval(Quad($1.value), Quad($3.value)));
@@ -574,10 +574,10 @@ RE_Quadruple:
     if ($3 == 0 && $5 == 0 && $7 == 0 && $9 == 0) TTCN_pattern_error("Zero "
       "character (i.e. quadruple `\\q{0,0,0,0}') is not supported in a "
       "pattern for type universal charstring.");
-    $$.comp.group = (unsigned char)$3;
-    $$.comp.plane = (unsigned char)$5;
-    $$.comp.row = (unsigned char)$7;
-    $$.comp.cell = (unsigned char)$9;
+    $$.comp.group = static_cast<unsigned char>($3);
+    $$.comp.plane = static_cast<unsigned char>($5);
+    $$.comp.row = static_cast<unsigned char>($7);
+    $$.comp.cell = static_cast<unsigned char>($9);
   }
 ;
 
@@ -611,7 +611,7 @@ char* TTCN_pattern_to_regexp_uni(const char* p_pattern, bool p_nocase, int** gro
   // needed by regexp to find user specified groups
   if (user_groups /*&& groups*/) {
     if (groups) {
-      *groups = (int*)Malloc(sizeof(int) * (user_groups + 1));
+      *groups = static_cast<int*>(Malloc(sizeof(int) * (user_groups + 1)));
       (*groups)[0] = user_groups;
     }
 
@@ -627,7 +627,7 @@ char* TTCN_pattern_to_regexp_uni(const char* p_pattern, bool p_nocase, int** gro
       }
     }
   } else if (groups)
-    *groups = (int*)0;
+    *groups = static_cast<int*>(0);
 
   return ret_val;
 }
diff --git a/compiler2/Type_chk.cc b/compiler2/Type_chk.cc
index 5e0c32a48a7676c396e05a102202d127a66bf877..f4dd0c7576bf7a96ed324a2f363cd3b7b5591859 100644
--- a/compiler2/Type_chk.cc
+++ b/compiler2/Type_chk.cc
@@ -5541,7 +5541,6 @@ bool Type::chk_this_template_generic(Template *t, namedbool incomplete_allowed,
       t->error("Generic wildcard `%s' cannot be used for signature `%s'",
                t->get_templatetype_str(), type->get_fullname().c_str());
     break;}
-  case Ttcn::Template::VALUE_LIST_ALL_FROM:
   case Ttcn::Template::ALL_FROM: {
     Ttcn::Template *af = t->get_all_from();
     switch (af->get_templatetype()) {
diff --git a/compiler2/Value.cc b/compiler2/Value.cc
index 587800c6ca7701826e5c394b52d3ad0151cbd2e6..58a44ce072cbf5985f0f6c2e70db5df003b2d695 100644
--- a/compiler2/Value.cc
+++ b/compiler2/Value.cc
@@ -10331,7 +10331,6 @@ error:
       self_ref |= (ass == lhs);
       break; }
     case Ttcn::Template::ALL_FROM:
-    case Ttcn::Template::VALUE_LIST_ALL_FROM:
       self_ref |= chk_expr_self_ref_templ(t->get_all_from(), lhs);
       break;
     case Ttcn::Template::TEMPLATE_LIST:
diff --git a/compiler2/subtype.cc b/compiler2/subtype.cc
index 322aaa6bbae7136c5ccce8e32f1252b8c4cf2faf..299f01a7681c1bae5ea0bc1ab16a4d9aa1457780 100644
--- a/compiler2/subtype.cc
+++ b/compiler2/subtype.cc
@@ -1951,7 +1951,6 @@ void SubType::chk_this_template(Template *templ)
     /* Should be canonical before */
     break;
   case Template::ALL_FROM:
-  case Template::VALUE_LIST_ALL_FROM:
   case Template::DECODE_MATCH:
   case Template::TEMPLATE_CONCAT:
     break;
diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc
index d39f5e771a9b7a714697e85e1639de4efd212b52..8ee30a2e97c39b0e8e147909809bdd15641f4207 100644
--- a/compiler2/ttcn3/AST_ttcn3.cc
+++ b/compiler2/ttcn3/AST_ttcn3.cc
@@ -8285,7 +8285,6 @@ namespace Ttcn {
       break; }
 
     case Template::ALL_FROM:
-    case Template::VALUE_LIST_ALL_FROM:
       FATAL_ERROR("should have been flattened");
       break;
     case Template::SUPERSET_MATCH:
diff --git a/compiler2/ttcn3/TtcnTemplate.cc b/compiler2/ttcn3/TtcnTemplate.cc
index f84a83b9dbfb605d48d8f4373b0d09a6cbd43bef..f5335c0064ec7059a1592c36e08616db8fdb1784 100644
--- a/compiler2/ttcn3/TtcnTemplate.cc
+++ b/compiler2/ttcn3/TtcnTemplate.cc
@@ -63,7 +63,6 @@ namespace Ttcn {
       u.invoke.ap_list = p.u.invoke.ap_list ? p.u.invoke.ap_list->clone() : 0;
       break;
     case ALL_FROM:
-    case VALUE_LIST_ALL_FROM:
       u.all_from = p.u.all_from->clone();
       break;
     case TEMPLATE_LIST:
@@ -137,7 +136,6 @@ namespace Ttcn {
       delete u.templates;
       break;
     case ALL_FROM:
-    case VALUE_LIST_ALL_FROM:
       delete u.all_from;
       break;
     case NAMED_TEMPLATE_LIST:
@@ -431,18 +429,6 @@ namespace Ttcn {
     // calling set_lowerid_to_ref is too soon (my_scope is not set yet)
   }
 
-  Template::Template(templatetype_t tt, Template *t)
-  : GovernedSimple(S_TEMPLATE)
-  , templatetype(VALUE_LIST_ALL_FROM), my_governor(0), length_restriction(0)
-  , is_ifpresent(false), specific_value_checked(false)
-  , has_permutation(false), flattened(true), base_template(0)
-  {
-    if (tt != VALUE_LIST_ALL_FROM) FATAL_ERROR("Template::Template()");
-    u.all_from = t->u.all_from; // take it over
-    t->u.all_from = NULL;
-    delete t;
-  }
-
   Template::Template(NamedTemplates *nts)
     : GovernedSimple(S_TEMPLATE),
       templatetype(NAMED_TEMPLATE_LIST), my_governor(0), length_restriction(0),
@@ -574,7 +560,6 @@ namespace Ttcn {
       u.named_templates->set_fullname(p_fullname);
       break;
     case ALL_FROM:
-    case VALUE_LIST_ALL_FROM:
       u.all_from->set_fullname(p_fullname);
       break;
     case VALUE_LIST:
@@ -636,7 +621,6 @@ namespace Ttcn {
       if(u.invoke.ap_list) u.invoke.ap_list->set_my_scope(p_scope);
       break;
     case ALL_FROM:
-    case VALUE_LIST_ALL_FROM:
       u.all_from->set_my_scope(p_scope);
       break;
     case TEMPLATE_LIST:
@@ -930,7 +914,6 @@ namespace Ttcn {
     case TEMPLATE_INVOKE:
       return "template returning invoke";
     case ALL_FROM:
-    case VALUE_LIST_ALL_FROM:
       return "template with 'all from'";
     case TEMPLATE_LIST:
       return "value list notation";
@@ -1353,8 +1336,7 @@ namespace Ttcn {
 
   Template *Template::get_all_from() const
   {
-    if (templatetype != ALL_FROM
-      &&templatetype != VALUE_LIST_ALL_FROM)
+    if (templatetype != ALL_FROM)
       FATAL_ERROR("Template::get_all_from()");
     return u.all_from;
   }
@@ -2713,24 +2695,6 @@ end:
         Template *& t = u.templates->get_t_byIndex(i);
         // the element in the (,,,)
         switch (t->templatetype) {
-        case VALUE_LIST_ALL_FROM: {
-          // the all from from something like subset(1, (all from...), 99)
-          // value list: one out of many possible values^^^^^^^^^^^^^
-          Location tloc(*t); // save the location info
-          string tname(t->get_fullname());
-          Templates *ha = harbinger(t, from_permutation, true);
-          if (ha) {
-            // Don't touch t from now on, it might have been deleted!
-            Template *qq = new Template(VALUE_LIST, ha);
-            qq->set_location(tloc);
-            qq->set_fullname(tname + ".all_from");
-            new_templates->add_t(qq);
-          }
-          else {
-            new_templates->add_t(t); // transfer it unchanged
-            flattened = false;
-          }
-          break; }
 
         case ALL_FROM: { // subset(1, all from ..., 99)
           // some number of elements--^^^^^^^^^^^^
@@ -2778,16 +2742,6 @@ end:
 
       break; }
 
-    case VALUE_LIST_ALL_FROM: {
-      Templates *new_templates = harbinger(this, from_permutation, false);
-      if (new_templates) {
-        delete u.all_from;
-        // now we can change the type
-        templatetype = VALUE_LIST;
-        u.templates = new_templates;
-      }
-      break; }
-    
     case TEMPLATE_ERROR: case TEMPLATE_NOTUSED:
     case OMIT_VALUE:     case ANY_VALUE: case ANY_OR_OMIT:
     case SPECIFIC_VALUE:
@@ -3285,9 +3239,6 @@ end:
     case NAMED_TEMPLATE_LIST:
       str = generate_code_init_se(str, name);
       break;
-    case VALUE_LIST_ALL_FROM:
-      str = generate_code_init_all_from_list(str, name);
-      break;
     case ALL_FROM:
       str = generate_code_init_all_from(str, name);
       break;
@@ -3594,7 +3545,6 @@ end:
   {
     switch (templatetype) {
     case ALL_FROM:
-    case VALUE_LIST_ALL_FROM:
       return false;
     case TEMPLATE_ERROR: /**< erroneous template */
     case TEMPLATE_NOTUSED: /**< not used symbol (-) */
@@ -4181,52 +4131,6 @@ compile_time:
     return str;
   }
 
-  char *Template::generate_code_init_all_from_list(char *str, const char *name)
-  {
-    // FIXME: this is the third instance
-    expression_struct expr;
-    Code::init_expr(&expr);
-    switch (u.all_from->templatetype) {
-    case SPECIFIC_VALUE: {
-      Value *spec = u.all_from->u.specific_value;
-      switch (spec->get_valuetype()) {
-      case Common::Value::V_REFD: {
-        Common::Reference  *ref = spec->get_reference();
-        Ref_pard* ref_pard = dynamic_cast<Ref_pard*>(ref);
-        if (ref_pard)
-          ref_pard->generate_code_cached(&expr);
-        else
-          ref->generate_code(&expr);
-        break; }
-      default:
-        FATAL_ERROR("vtype %d", spec->get_valuetype());
-        break;
-      }
-      break; }
-
-    default:
-      FATAL_ERROR("ttype %d", u.all_from->templatetype);
-      break;
-    }
-
-    if (expr.preamble)
-     str = mputstr(str, expr.preamble);
-    
-    str = mputprintf(str,
-      "%s.set_type(VALUE_LIST, %s.n_elem());\n"
-      "for (int i_i = 0, i_lim = %s.n_elem(); i_i < i_lim; ++i_i) {\n",
-      name,
-      expr.expr,
-      expr.expr);
-    string embedded_name(name);
-    embedded_name += ".list_item(i_i)";
-    str = generate_code_init_all_from(str, embedded_name.c_str());
-    str = mputstrn(str, "}\n", 2);
-
-    Code::free_expr(&expr);
-    return str;
-  }
-
   char *Template::generate_code_init_se(char *str, const char *name)
   { // named template list
     Type *type = my_governor->get_type_refd_last();
@@ -4320,16 +4224,13 @@ compile_time:
           Code::free_expr(&expr);
         }
         else {
-          str_set_type = mputstr (str_set_type, ass->get_id().get_name().c_str());
-          if (subrefs) {
-            expression_struct expr;
-            Code::init_expr(&expr);
+          expression_struct expr;
+          Code::init_expr(&expr);
 
-            subrefs->generate_code(&expr, ass);
-            str_set_type = mputprintf(str_set_type, "%s", expr.expr);
+          ref->generate_code(&expr);
+          str_set_type = mputprintf(str_set_type, "%s", expr.expr);
 
-            Code::free_expr(&expr);
-          }
+          Code::free_expr(&expr);
         }
         
         switch(ass->get_asstype()) {
@@ -4370,8 +4271,6 @@ compile_time:
       for (size_t vi = 0; vi < nof_ts; ++vi) {
         Template *t = u.templates->get_t_byIndex(vi);
         switch (t->templatetype) {
-        case VALUE_LIST_ALL_FROM:
-          FATAL_ERROR("VALUE_LIST_ALL_FROM not handled");
         case ALL_FROM: {
           expression_struct expr;
           Code::init_expr(&expr);
@@ -4648,9 +4547,6 @@ compile_time:
           shifty += ".n_elem() /* 3442 */";
           Code::free_expr(&expr);
           break; }
-        case VALUE_LIST_ALL_FROM:
-          FATAL_ERROR("Not possible");
-          break; // not reached
 
         default:
           if (t->needs_temp_ref()) {
@@ -4998,7 +4894,6 @@ compile_time:
     case NAMED_TEMPLATE_LIST:
       return u.named_templates->get_nof_nts() > 1;
     case ALL_FROM:
-    case VALUE_LIST_ALL_FROM:
       return false;
     case VALUE_LIST:
     case COMPLEMENTED_LIST:
@@ -5069,7 +4964,6 @@ compile_time:
     case DECODE_MATCH:
       return false;
     case ALL_FROM:
-    case VALUE_LIST_ALL_FROM:
       return false;
     case TEMPLATE_CONCAT:
       return u.concat.op1->has_single_expr() && u.concat.op2->has_single_expr();
@@ -5222,7 +5116,6 @@ compile_time:
       u.pstring->dump(level+1);
       break;
     case ALL_FROM:
-    case VALUE_LIST_ALL_FROM:
       u.all_from->dump(level+1);
       break;
     case DECODE_MATCH:
diff --git a/compiler2/ttcn3/TtcnTemplate.hh b/compiler2/ttcn3/TtcnTemplate.hh
index b55d19fda53c8d80d031c3691b08983b1afee3f6..6f664fe835c07d754dd953607c64405844994814 100644
--- a/compiler2/ttcn3/TtcnTemplate.hh
+++ b/compiler2/ttcn3/TtcnTemplate.hh
@@ -63,7 +63,6 @@ namespace Ttcn {
       SUBSET_MATCH, /**< subset match */
       PERMUTATION_MATCH, /**< permutation match */
       ALL_FROM, /**< "all from" as part of a larger list e.g. permutation, superset, subset, etc. */
-      VALUE_LIST_ALL_FROM, /**< "all from" in a value list, itself in a larger list */
       BSTR_PATTERN, /**< bitstring pattern */
       HSTR_PATTERN, /**< hexstring pattern */
       OSTR_PATTERN, /**< octetstring pattern */
@@ -196,11 +195,6 @@ namespace Ttcn {
     /** Constructor for ALL_FROM */
     Template(Template*);
 
-    /** Constructor for VALUE_LIST_ALL_FROM
-     *  Takes over the innards of \a t, then deletes it.
-     *  @pre tt == VALUE_LIST_ALL_FROM */
-    Template(templatetype_t tt, Template *t);
-
     /** Constructor for NAMED_TEMPLATE_LIST */
     Template(NamedTemplates *nts);
 
diff --git a/compiler2/ttcn3/compiler.y b/compiler2/ttcn3/compiler.y
index 476095e5d8db49c00fe8153409e3574b42841ca9..98108799c6e69b23a5d8b515d7a80e2293600a56 100644
--- a/compiler2/ttcn3/compiler.y
+++ b/compiler2/ttcn3/compiler.y
@@ -130,7 +130,6 @@ static const string anyname("anytype");
   bool bool_val; /* boolean value */
   char *str; /* simple string value */
   unsigned char uchar_val;
-
   int_val_t *int_val; /* integer value */
   Real float_val; /* float value */
   Identifier *id;
@@ -1867,12 +1866,12 @@ optDecodedModifier
 %left '*' '/' ModKeyword RemKeyword
 %left UnarySign
 
-%expect 63
+%expect 65
 
 %start GrammarRoot
 
 /*
-XXX Source of conflicts (63 S/R):
+XXX Source of conflicts (65 S/R):
 
 1.) 9 conflicts in one state
 The Expression after 'return' keyword is optional in ReturnStatement.
@@ -1912,14 +1911,19 @@ non-standard language extension.
 
 6.) 1 Conflict due to pattern concatenation
 
-7.) 26 conflicts in one state
+7.) 27 conflicts in one state
 In the DecodedContentMatch rule a SingleExpression encased in round brackets is
 followed by an in-line template. For 26 tokens (after the ')' ) the parser cannot
 decide whether the token is the beginning of the in-line template (shift) or
 the brackets are only part of the SingleExpression itself and the conflicting
 token is the next segment in the expression (reduce).
 
-8.) 4 conflicts in 4 states
+8.) 1 conflict
+In the current version when the compiler finds '(' SingleExpression . ')'
+it can not decide if it should resolve to a SingleValueOrAttrib or to a SingleExpression.
+Shift is fine as single element list can be resolved via SingleValueOrAttrib too.
+
+9.) 4 conflicts in 4 states
 In the rules for 'running' and 'alive' operations with the 'any from' clause,
 the redirect operator ("->") after the 'running' or 'alive' keyword can be the
 start of the operation's index redirect (shift) or another expression that starts
@@ -1927,9 +1931,9 @@ with "->" (reduce).
 TODO: Find out what the index redirect conflicts with. It's probably something
 that would cause a semantic error anyway, but it would be good to know.
 
-9.) 2 conflicts in the rule TypeListWithTo.
+10.) 2 conflicts in the rule TypeListWithTo.
 
-10.) 4 conflicts in 4 states
+11.) 4 conflicts in 4 states
 In the Expression and SingleExpression rules when an AnyValue or AnyOrOmit is
 followed by a LengthMatch, the parser cannot decide whether the LengthMatch token
 belongs to the AnyValue/AnyOrOmit (shift) or the resulting template (reduce).
@@ -3707,11 +3711,6 @@ MatchingSymbol: // 116 is a Template*
     $$ = new Template(Template::SUPERSET_MATCH, $1);
     $$->set_location(infile, @$);
   }
-| '(' AllElementsFrom ')'
-  {
-    $$ = new Template(Template::VALUE_LIST_ALL_FROM, $2);
-    $$->set_location(infile, @$);
-  }
 ;
 
 optExtraMatchingAttributes: // [117]
@@ -3879,6 +3878,11 @@ ValueOrAttribList: // 142 is a Templates*
     $$ = $5;
     $$->add_front_t($2);
   }
+| '(' TemplateListElem optError ')'
+  {
+    $$ = new Templates;
+    $$->add_front_t($2);
+  }
 | '(' error TemplateListElem optError ',' seqValueOrAttrib optError ')'
   {
     $$ = $6;