diff --git a/matlab/swz/c-code/Makefile b/matlab/swz/c-code/Makefile
index 77cc02e5b7920ea51aca1b7fd345d776cf87ba77..54dcf77ba201c4a8ae926fdabbe30c19d036b96c 100644
--- a/matlab/swz/c-code/Makefile
+++ b/matlab/swz/c-code/Makefile
@@ -5,23 +5,25 @@
 # All output is to OUT_DIR
 
 # MACHINE
-USE_MICHEL_LAPTOP=USE_MICHEL_LAPTOP 
-
+STANDALONE_HB = STANDALONE_HB
+MACOSX = MACOSX
 
 # LIBRARIES
 USE_TAO = USE_TAO
-USE_MKL = USE_MKL
+#USE_MKL = USE_MKL
 #USE_IMSL = USE_IMSL
 USE_LAPACK = USE_LAPACK
 USE_FORTRAN = USE_FORTRAN
 USE_MATH = USE_MATH
-USE_GSL = USE_GLS
+USE_GSL = USE_GSL
 #USE_GSL_CBLAS = USE_GSL_CBLAS
 
 
 WORK_DIR = .
 OUT_DIR = ../bin
 
+CFLAGS = -g -DINTELCMATHLIBRARY
+
 # MACHINE DEPENDENT DIRECTORIES 
 
 # LAPTOP
@@ -31,7 +33,7 @@ OUT_DIR = /home/kalagman/Documents/InternshipJob/Dynare/work/
 
 CC = /usr/bin/gcc-4.3.2
 FC = gfortran
-CFLAGS = -g -static
+CFLAGS := $(CFLAGS) -static
 
 TAO_DIR = $(WORK_DIR)/utilities/TZCcode
 IMSL_BASE_DIR = /opt/vni/CTT6.0
@@ -53,8 +55,7 @@ ifdef USE_MICHEL_LAPTOP
 CC = gcc
 #CC = /opt/intel/Compiler/11.0/074/bin/intel64/icc -no-multibyte-chars
 FC = gfortran
-CFLAGS = -g -static
-#CFLAGS = -g
+CFLAGS := $(CFLAGS) -static
 
 TAO_DIR = $(WORK_DIR)/utilities/TZCcode
 
@@ -65,16 +66,32 @@ INTEL_LIBS_DIR = /opt/intel/Compiler/11.0/074/lib/intel64
 INTEL_LIBS = -lguide
 MKL_BASE_DIR = /opt/intel/Compiler/11.0/074/mkl
 MKL_LIBS_DIR = $(MKL_BASE_DIR)/lib/em64t
-MKL_LIBS = -lmkl_lapack -lmkl_em64t 
+MKL_LIBS = -lmkl_lapack -lmkl_em64t
+
+endif
+
+
+ifdef STANDALONE_HB
+CC = gcc
+FC = gfortran
+
+GSL_INCLUDE_DIR = /usr/local/include/gsl
+GSL_LIBS_DIR = /usr/local/lib
+
+TAO_DIR = $(WORK_DIR)/utilities/TZCcode
+endif
 
+ifdef MACOSX
+MAC_LIBS = -framework Accelerate
+CFLAGS := $(CFLAGS) -DMACOSX
 endif
 
 
 #################################################################################
 VPATH = 
-INCLUDE_DIR = 
+INCLUDE_DIR = -I/Applications/MatlabR2010a/MATLAB_R2010a.app/extern/include/
 LIBS_DIR = 
-LIBS = 
+LIBS = $(MAC_LIBS)
 OBJS =
 #################################################################################
 
@@ -233,6 +250,6 @@ $(OUT_DIR)/sbvar_probabilities: $(OBJS_PROBA)
 #
 #################################################################################
 clean:
-	rm -f $(OUT_DIR)/*.o 
+	rm -f $(OUT_DIR)/*.o *.o
 #
 #################################################################################
diff --git a/matlab/swz/c-code/utilities/DWCcode/arrays/dw_array.c b/matlab/swz/c-code/utilities/DWCcode/arrays/dw_array.c
index db0d67491e6f5938ef2ff924290b334d045eb9de..842a77dd293af806851c989415f0b07ecd1436ed 100644
--- a/matlab/swz/c-code/utilities/DWCcode/arrays/dw_array.c
+++ b/matlab/swz/c-code/utilities/DWCcode/arrays/dw_array.c
@@ -4,7 +4,12 @@
 
 #include <stdlib.h>
 #include <string.h>
+
+#if defined(MACOSX)
+#include <sys/malloc.h>
+#else
 #include <malloc.h>
+#endif
 #include <stdarg.h>
 
 //================================== Macros ===================================//
diff --git a/matlab/swz/c-code/utilities/TZCcode/tzmatlab_dw.h b/matlab/swz/c-code/utilities/TZCcode/tzmatlab_dw.h
index 0d2449ae007127c9da3503d1bf202a61c322ffea..e14ba5f8ebdb8e065bd76785cbc18d8c66066abb 100644
--- a/matlab/swz/c-code/utilities/TZCcode/tzmatlab_dw.h
+++ b/matlab/swz/c-code/utilities/TZCcode/tzmatlab_dw.h
@@ -63,7 +63,7 @@
 //#define USE_IMSL_MATH_LIBRARY
 //#define USE_IMSL_STAT_LIBRARY
 #define USE_GSL_LIBRARY
-#define USE_MKL_LIBRARY
+//#define USE_MKL_LIBRARY
 /*******************************************************************************/
 
 // #define NEWVERSIONofDW_SWITCH //If defined, using DW's new switch program (implemented in 2008),
@@ -75,7 +75,7 @@
    #define SWITCHTOIMSLCMATH             // define: use IMSL special functions like gammlog; undef: use my own default code if it exists.
 
    //-------Only one of the following for math library.--------
-   #define INTELCMATHLIBRARY             // define: use Intel MKL LAPACK library; undef: use others.
+//   #define INTELCMATHLIBRARY             // define: use Intel MKL LAPACK library; undef: use others.
    //#define IMSLCMATHLIBRARY         // define: use IMSL C Math library; undef: use others.
    //#define MATLABCMATHLIBRARY            // define: use Matlab C math library; undef: use others.
 
@@ -107,7 +107,7 @@
    #endif       
    #include "blas_lapack.h"  
    #undef  SWITCHTOINTELCMATH
-   #undef  INTELCMATHLIBRARY 
+//   #undef  INTELCMATHLIBRARY 
 #endif
 
 #if defined(USE_GSL_LIBRARY)
diff --git a/matlab/swz/sz_prd.m b/matlab/swz/sz_prd.m
index bfd5f49c100e1349d1789cb551a6bceb7c1d5a99..54f015b1818356d925a6870b2a4d848f6949775a 100644
--- a/matlab/swz/sz_prd.m
+++ b/matlab/swz/sz_prd.m
@@ -498,7 +498,7 @@ end
 if options_.ms.estimate_msmodel == 1
     if use_linux == 1
         perform_estimation=[c_path,'/sbvar_estimation -ft ',options_.ms.output_file_tag];
-        %        system(perform_estimation);
+        system(perform_estimation);
     else
         perform_estimation=[c_path,'\sbvar_estimation.exe -ft ',options_.ms.output_file_tag];
         dos(perform_estimation)