diff --git a/compiler2/CodeGenHelper.cc b/compiler2/CodeGenHelper.cc
index f903b70a880065e63eb9f7702811658915ad3dee..a71fa94f9370aed5fbdc420ef1c31eacb0ff9f94 100644
--- a/compiler2/CodeGenHelper.cc
+++ b/compiler2/CodeGenHelper.cc
@@ -196,7 +196,7 @@ void CodeGenHelper::update_intervals(output_struct* const output) {
   tmp = mstrlen(output->source.function_bodies);
   if (output->intervals.function_bodies[output->intervals.function_bodies_size] < tmp) {
     output->intervals.function_bodies_size++;
-    if (output->intervals.function_bodies_size > output->intervals.function_bodies_max_size) {
+    if (output->intervals.function_bodies_size >= output->intervals.function_bodies_max_size) {
       output->intervals.function_bodies_max_size *= 2;
       output->intervals.function_bodies = (size_t*)Realloc(output->intervals.function_bodies, output->intervals.function_bodies_max_size * sizeof(size_t));
     }
@@ -205,7 +205,7 @@ void CodeGenHelper::update_intervals(output_struct* const output) {
   tmp = mstrlen(output->source.methods);
   if (output->intervals.methods[output->intervals.methods_size] < tmp) {
     output->intervals.methods_size++;
-    if (output->intervals.methods_size > output->intervals.methods_max_size) {
+    if (output->intervals.methods_size >= output->intervals.methods_max_size) {
       output->intervals.methods_max_size *= 2;
       output->intervals.methods = (size_t*)Realloc(output->intervals.methods, output->intervals.methods_max_size * sizeof(size_t));
     }
@@ -214,7 +214,7 @@ void CodeGenHelper::update_intervals(output_struct* const output) {
   tmp = mstrlen(output->source.static_conversion_function_bodies);
   if (output->intervals.static_conversion_function_bodies[output->intervals.static_conversion_function_bodies_size] < tmp) {
     output->intervals.static_conversion_function_bodies_size++;
-    if (output->intervals.static_conversion_function_bodies_size > output->intervals.static_conversion_function_bodies_max_size) {
+    if (output->intervals.static_conversion_function_bodies_size >= output->intervals.static_conversion_function_bodies_max_size) {
       output->intervals.static_conversion_function_bodies_max_size *= 2;
       output->intervals.static_conversion_function_bodies = (size_t*)Realloc(output->intervals.static_conversion_function_bodies, output->intervals.static_conversion_function_bodies_max_size * sizeof(size_t));
     }
@@ -223,7 +223,7 @@ void CodeGenHelper::update_intervals(output_struct* const output) {
   tmp = mstrlen(output->source.static_function_bodies);
   if (output->intervals.static_function_bodies[output->intervals.static_function_bodies_size] < tmp) {
     output->intervals.static_function_bodies_size++;
-    if (output->intervals.static_function_bodies_size > output->intervals.static_function_bodies_max_size) {
+    if (output->intervals.static_function_bodies_size >= output->intervals.static_function_bodies_max_size) {
       output->intervals.static_function_bodies_max_size *= 2;
       output->intervals.static_function_bodies = (size_t*)Realloc(output->intervals.static_function_bodies, output->intervals.static_function_bodies_max_size * sizeof(size_t));
     }
diff --git a/regression_test/XML/XmlWorkflow/bin/prj2mk.pl b/regression_test/XML/XmlWorkflow/bin/prj2mk.pl
index fcb4b6454e94dab09e7f39ed41d0bab80e6798c8..9469a6f0c57f5af09103bde1f1470cd745046e9c 100644
--- a/regression_test/XML/XmlWorkflow/bin/prj2mk.pl
+++ b/regression_test/XML/XmlWorkflow/bin/prj2mk.pl
@@ -87,22 +87,33 @@ delete @files{ @excluded };
 
 my @files = keys %files;
 
+
 # Filter out files which are in the current directory.
 # They should not be symlinked
 my @symlinkfiles = $local_prj ? @files : grep { $_ !~ m(^./) } @files;
 
+my @xsdfiles = grep(/.xsd/, @files);
+
+#filter xsd files from all files
+my %in_xsdfiles = map {$_ => 1} @xsdfiles;
+my @files_without_xsd  = grep {not $in_xsdfiles{$_}} @files;
+
 # Symlink all files into bin/
 print "Symlinking " . scalar @symlinkfiles . " files\n";
 system("ln -s @symlinkfiles ./");
 
 # Remove the path from the filenames
-map { s!.+/!!g } @files;
+map { s!.+/!!g } @files_without_xsd;
+map { s!.+/!!g } @xsdfiles;
+#add the xsd files as other files
+my $prefix = "-O ";
+my $xsdfiles2 = join " ", map { $prefix . $_ } @xsdfiles;
 
 # Generate the makefile
 print("LD_LIBRARY_PATH is $ENV{LD_LIBRARY_PATH}\n");#temporary debug printout
-print("$ENV{TTCN3_DIR}/bin/ttcn3_makefilegen -gs $split $rt2 -e XmlTest @files\n");
+print("$ENV{TTCN3_DIR}/bin/ttcn3_makefilegen -gs $split $rt2 -e XmlTest @files_without_xsd $xsdfiles2 \n");
 
-system(   "\$TTCN3_DIR/bin/ttcn3_makefilegen -gs $split $rt2 -e XmlTest -o Makefile.1 @files");
+system(   "\$TTCN3_DIR/bin/ttcn3_makefilegen -gs $split $rt2 -e XmlTest -o Makefile.1 @files_without_xsd $xsdfiles2");
 
 # Post-process the generated makefile
 open(MAKEFILE_IN , '<' . 'Makefile.1') or die "open input: $!";
diff --git a/regression_test/compileonly/mfgen-xsd/Makefile b/regression_test/compileonly/mfgen-xsd/Makefile
index 9dff81811001cb5abde5cd8abd9ba10e0c071d71..02a33d7122aa740292bbe36a29e779f6386785e1 100644
--- a/regression_test/compileonly/mfgen-xsd/Makefile
+++ b/regression_test/compileonly/mfgen-xsd/Makefile
@@ -19,14 +19,9 @@ endif
 MFGEN := $(TTCN3_DIR)/bin/ttcn3_makefilegen
 MFGEN_FLAGS := -sf $(RT2_FLAG) $(SPLIT_FLAG)
 
-# ${MAKEPROG} has the same content as the built-in ${MAKE},
-# except the special handling of ${MAKE} does not apply.
-# If we used ${MAKE} in the rules below, 'make -n' would succeed once,
-# then fail on every subsequent invocation until a 'make clean' is done. 
-MAKEPROG := ${MAKE}
-
-all: normal centralstorage centralstorage_with_normal recursive_tpd improved_linking
+CURRENT_DIR := $(shell pwd)
 
+LD_LIBRARY_PATH := $(LD_LIBRARY_PATH):$(CURRENT_DIR)/normal:$(CURRENT_DIR)/centralstorage
 
 NORMAL_NORMAL_FILES := MainNormal.ttcn
 
@@ -42,51 +37,58 @@ EXT_NORMAL_FILES := $(addprefix ../normal/, $(NORMAL_FILES))
 
 EXT_NORMAL_NORMAL_FILES := $(addprefix ../normal/, $(NORMAL_NORMAL_FILES))
 
+# ${MAKEPROG} has the same content as the built-in ${MAKE},
+# except the special handling of ${MAKE} does not apply.
+# If we used ${MAKE} in the rules below, 'make -n' would succeed once,
+# then fail on every subsequent invocation until a 'make clean' is done. 
+MAKEPROG := ${MAKE}
+
+all: normal centralstorage centralstorage_with_normal recursive_tpd improved_linking
 
 normal:
 	#Normal tests with various switches
 	cd normal && $(MFGEN) $(MFGEN_FLAGS) $(NORMAL_FILES) && $(MAKEPROG) \
-	&& ./Main normal.cfg && make clean && make port && make clean && make check \
+	&& ./Main normal.cfg && make clean && make port && make check \
 	&& make clean
 
 	cd normal && $(MFGEN) $(MFGEN_FLAGS) -p $(NORMAL_FILES) && $(MAKEPROG) \
-	&& ./Main normal.cfg && make clean && make port && make clean && make check \
+	&& ./Main normal.cfg && make clean && make port && make check \
 	&& make clean
 
 	cd normal && $(MFGEN) $(MFGEN_FLAGS) -g $(NORMAL_FILES) && $(MAKEPROG) \
-	&& ./Main normal.cfg && make clean && make port && make clean && make check \
+	&& ./Main normal.cfg && make clean && make port && make check \
 	&& make clean
 
 	cd normal && $(MFGEN) $(MFGEN_FLAGS) -U type $(NORMAL_FILES) && $(MAKEPROG) \
-	&& ./Main normal.cfg && make clean && make port && make clean && make check \
+	&& ./Main normal.cfg && make clean && make port && make check \
 	&& make clean
 
 	cd normal && $(MFGEN) $(MFGEN_FLAGS) -U 5 $(NORMAL_FILES) && $(MAKEPROG) \
-	&& ./Main normal.cfg && make clean && make port && make clean && make check \
+	&& ./Main normal.cfg && make clean && make port && make check \
 	&& make clean
 
 	cd normal && $(MFGEN) $(MFGEN_FLAGS) -l $(NORMAL_FILES) && $(MAKEPROG) \
-	&& ./Main normal.cfg && make clean && make port && make clean && make check \
+	&& ./Main normal.cfg && make clean && make port && make check \
 	&& make clean && make shared_objects && make clean
 
 	cd normal && $(MFGEN) $(MFGEN_FLAGS) -L $(NORMAL_FILES) && $(MAKEPROG) \
-	&& make clean && make port && make clean && make check \
+	&& make clean && make port && make check \
 	&& make clean
 
 	cd normal && $(MFGEN) $(MFGEN_FLAGS) -pg $(NORMAL_FILES) && $(MAKEPROG) \
-	&& ./Main normal.cfg && make clean && make port && make clean && make check \
+	&& ./Main normal.cfg && make clean && make port && make check \
 	&& make clean
 
 	cd normal && $(MFGEN) $(MFGEN_FLAGS) -pl -U type $(NORMAL_FILES) && $(MAKEPROG) \
-	&& ./Main normal.cfg && make clean && make port && make clean && make check \
+	&& ./Main normal.cfg && make clean && make port && make check \
 	&& make clean && make shared_objects && make clean
 
 	cd normal && $(MFGEN) $(MFGEN_FLAGS) -pgl $(NORMAL_FILES) && $(MAKEPROG) \
-	&& ./Main normal.cfg && make clean && make port && make clean && make check \
+	&& ./Main normal.cfg && make clean && make port && make check \
 	&& make clean && make shared_objects && make clean
 
 	cd normal && $(MFGEN) $(MFGEN_FLAGS) -pgl -U type $(NORMAL_FILES) && $(MAKEPROG) \
-	&& ./Main normal.cfg && make clean && make port && make clean && make check \
+	&& ./Main normal.cfg && make clean && make port && make check \
 	&& make clean && make shared_objects && make clean
 
 	cd normal && rm -rf Makefile
@@ -99,31 +101,31 @@ centralstorage:
 
 	cd centralstorage && $(MFGEN) $(MFGEN_FLAGS) -c $(EXT_FILES) $(EXT_NORMAL_FILES) \
 	&& $(MAKEPROG) && ./MainExt config.cfg \
-	&& make clean && make port && make clean && make check && make clean
+	&& make clean && make port && make check && make clean
 
 	cd centralstorage && $(MFGEN) $(MFGEN_FLAGS) -cp $(EXT_FILES) $(EXT_NORMAL_FILES) \
 	&& $(MAKEPROG) && ./MainExt config.cfg \
-	&& make clean && make port && make clean && make check && make clean
+	&& make clean && make port && make check && make clean
 
 	cd centralstorage && $(MFGEN) $(MFGEN_FLAGS) -cg $(EXT_FILES) $(EXT_NORMAL_FILES) \
 	&& $(MAKEPROG) && ./MainExt config.cfg \
-	&& make clean && make port && make clean && make check && make clean
+	&& make clean && make port && make check && make clean
 
 	cd centralstorage && $(MFGEN) $(MFGEN_FLAGS) -cl $(EXT_FILES) $(EXT_NORMAL_FILES) \
 	&& $(MAKEPROG) && ./MainExt config.cfg \
-	&& make clean && make port && make clean && make check && make clean \
+	&& make clean && make port && make check && make clean \
 	&& make shared_objects && make clean
 
 	cd centralstorage && $(MFGEN) $(MFGEN_FLAGS) -cL $(EXT_FILES) $(EXT_NORMAL_FILES) \
-	&& $(MAKEPROG) && make clean && make port && make clean && make check && make clean
+	&& $(MAKEPROG) && make clean && make port && make check && make clean
 
 	cd centralstorage && $(MFGEN) $(MFGEN_FLAGS) -cpg $(EXT_FILES) $(EXT_NORMAL_FILES) \
 	&& $(MAKEPROG) && ./MainExt config.cfg \
-	&& make clean && make port && make clean && make check && make clean
+	&& make clean && make port && make check && make clean
 
 	cd centralstorage && $(MFGEN) $(MFGEN_FLAGS) -cpgl $(EXT_FILES) $(EXT_NORMAL_FILES) \
 	&& $(MAKEPROG) && ./MainExt config.cfg \
-	&& make clean && make port && make clean && make check && make clean \
+	&& make clean && make port && make check && make clean \
 	&& make shared_objects && make clean
 
 	# For the tests with -U type the 'base' should be compiled with -U type
@@ -131,23 +133,23 @@ centralstorage:
 
 	cd centralstorage && $(MFGEN) $(MFGEN_FLAGS) -c -U type $(EXT_FILES) $(EXT_NORMAL_FILES) \
 	&& $(MAKEPROG) && ./MainExt config.cfg \
-	&& make clean && make port && make clean && make check && make clean
+	&& make clean && make port && make check && make clean
 
 	cd centralstorage && $(MFGEN) $(MFGEN_FLAGS) -cpl -U type $(EXT_FILES) $(EXT_NORMAL_FILES) \
 	&& $(MAKEPROG) && ./MainExt config.cfg \
-	&& make clean && make port && make clean && make check && make clean \
+	&& make clean && make port && make check && make clean \
 	&& make shared_objects && make clean
 
 	cd centralstorage && $(MFGEN) $(MFGEN_FLAGS) -cpgl -U type $(EXT_FILES) $(EXT_NORMAL_FILES) \
 	&& $(MAKEPROG) && ./MainExt config.cfg \
-	&& make clean && make port && make clean && make check && make clean \
+	&& make clean && make port && make check && make clean \
 	&& make shared_objects && make clean
 
 	cd normal && make clean && $(MFGEN) $(MFGEN_FLAGS) -U 5 $(NORMAL_FILES) && $(MAKEPROG)
 
 	cd centralstorage && $(MFGEN) $(MFGEN_FLAGS) -c -U 5 $(EXT_FILES) $(EXT_NORMAL_FILES) \
 	&& $(MAKEPROG) && ./MainExt config.cfg \
-	&& make clean && make port && make clean && make check && make clean
+	&& make clean && make port && make check && make clean
 
 	cd normal && make clean && rm -rf *.so Makefile && cd ../centralstorage && rm -rf Makefile *.cc *.hh # Makefilegen error???
 
@@ -159,11 +161,11 @@ centralstorage_with_normal:
 
 	cd centralstorage && $(MFGEN) $(MFGEN_FLAGS) -c $(NORMAL_EXT_FILES) $(EXT_NORMAL_FILES) \
 	&& $(MAKEPROG) && ./MainExtNormal configNormal.cfg \
-	&& make clean && make port && make clean && make check && make clean
+	&& make clean && make port && make check && make clean
 
 	cd centralstorage && $(MFGEN) $(MFGEN_FLAGS) -cpg $(NORMAL_EXT_FILES) $(EXT_NORMAL_FILES) \
 	&& $(MAKEPROG) && ./MainExtNormal configNormal.cfg \
-	&& make clean && make port && make clean && make check && make clean
+	&& make clean && make port && make check && make clean
 
 	cd normal && make clean
 
@@ -171,11 +173,11 @@ centralstorage_with_normal:
 
 	cd centralstorage && $(MFGEN) $(MFGEN_FLAGS) -c $(EXT_NORMAL_NORMAL_FILES) $(EXT_FILES2) \
 	&& $(MAKEPROG) && ./MainNormal configNormal2.cfg \
-	&& make clean && make port && make clean && make check && make clean
+	&& make clean && make port && make check && make clean
 
 	cd centralstorage && $(MFGEN) $(MFGEN_FLAGS) -cpg $(EXT_NORMAL_NORMAL_FILES) $(EXT_FILES2) \
 	&& $(MAKEPROG) && ./MainNormal configNormal2.cfg \
-	&& make clean && make port && make clean && make check && make clean
+	&& make clean && make port && make check && make clean
 
 	cd normal && make clean && rm -rf Makefile && cd ../centralstorage && rm -rf Makefile *.cc *.hh
 
diff --git a/regression_test/compileonly/mfgen-xsd/config.cfg b/regression_test/compileonly/mfgen-xsd/config.cfg
index 761d4b82c22e9f35f557ea321f6efbc146223c4e..3375600eadba6791ec0d40887970a7fd10fbb3b6 100644
--- a/regression_test/compileonly/mfgen-xsd/config.cfg
+++ b/regression_test/compileonly/mfgen-xsd/config.cfg
@@ -16,5 +16,6 @@ MainExt.control
 MainExtNormal.control
 MainExt2.control
 MainExt2Normal.control
-TopMain.control
-TopMainNormal.control
\ No newline at end of file
+#SOLARIS does not find these control parts
+#TopMain.control
+#TopMainNormal.control