diff --git a/build_moose_core.sh.in b/build_moose_core.sh.in
index ff9587aef0dc66d4e56637782e27b1720e323005..b0dc795a3c45151089972cf86947f385be4f2635 100755
--- a/build_moose_core.sh.in
+++ b/build_moose_core.sh.in
@@ -16,5 +16,6 @@ echo "Building MOOSE"
         @MOOSE_CORE_SOURCE_DIR@ 
     $MAKE
     $MAKE install
+    ctest --output-on-failure || echo "Some tests failed"
 )
 
diff --git a/moose-core/CMakeLists.txt b/moose-core/CMakeLists.txt
index bca3590a98fd8e5f086cf14ab03ef10c7d120c10..d9233825d0eeb7e1251db30af60756e003c7a624 100644
--- a/moose-core/CMakeLists.txt
+++ b/moose-core/CMakeLists.txt
@@ -157,42 +157,28 @@ include_directories(msg basecode)
 set_target_properties(libmoose PROPERTIES COMPILE_DEFINITIONS  "MOOSE_LIB")
 set_target_properties(libmoose PROPERTIES PREFIX "")
 
+## Variable to collect all static libraries.
+set(STATIC_LIBRARIES "" )
+
 if(WITH_GSL)
-    if(GSL_STATIC_HOME)
-        SET(GSL_INCLUDE_DIRS "${GSL_STATIC_HOME}/include")
-        find_library(GSL_LIBRARY 
-            NAME libgsl.a 
-            PATHS ${GSL_STATIC_HOME}/lib ${GSL_STATIC_HOME}/lib64
-            NO_DEFAULT_PATH
-            )
-        find_library(GSLCBLAS_LIBRARY
-            NAME libgslcblas.a 
-            PATHS ${GSL_STATIC_HOME}/lib ${GSL_STATIC_HOME}/lib64 
-            NO_DEFAULT_PATH
+    find_package(GSL 1.16)
+    if(NOT GSL_FOUND)
+        message(FATAL_ERROR 
+            "=====================================================================\n"
+            " FATAL gsl(>1.16) not found.\n\n"
+            " MOOSE requires Gnu Scientific Library (GSL) 1.16 or higher. \n"
+            " Please install the `dev` or `devel` package e.g. \n"
+            "     $ sudo apt-get install libgsl0-dev \n"
+            "     $ sudo yum install libgsl-devel \n"
+            "     $ brew install gsl \n\n"
+            " Or build and install gsl from source code \n"
+            "     https://www.gnu.org/software/gsl/ \n"
+            " After installing gsl, rerun cmake.\n\n"
+            " If you install gsl in non-standard place, set the GSL_HOME environment \n"
+            " variable. CMAKE use this to search for required files. \n"
+            "====================================================================\n"
             )
-        SET(GSL_LIBRARIES ${GSL_LIBRARY} ${GSLCBLAS_LIBRARY})
-        message(STATUS "STATIC GSL_LIBRARIES ${GSL_LIBRARIES}")
-        set(GSL_FOUND TRUE)
-    ELSE()
-        find_package(GSL 1.16)
-        if(NOT GSL_FOUND)
-            message(FATAL_ERROR 
-                "=====================================================================\n"
-                " FATAL gsl(>1.16) not found.\n\n"
-                " MOOSE requires Gnu Scientific Library (GSL) 1.16 or higher. \n"
-                " Please install the `dev` or `devel` package e.g. \n"
-                "     $ sudo apt-get install libgsl0-dev \n"
-                "     $ sudo yum install libgsl-devel \n"
-                "     $ brew install gsl \n\n"
-                " Or build and install gsl from source code \n"
-                "     https://www.gnu.org/software/gsl/ \n"
-                " After installing gsl, rerun cmake.\n\n"
-                " If you install gsl in non-standard place, set the GSL_HOME environment \n"
-                " variable. CMAKE use this to search for required files. \n"
-                "====================================================================\n"
-                )
-        endif(NOT GSL_FOUND)
-    endif()
+    endif(NOT GSL_FOUND)
     add_definitions(-DUSE_GSL)
     # GSL is also used in RNG (whenever applicable), therefore include paths are
     # top level.
@@ -232,6 +218,14 @@ endif(NOT HDF5_FOUND)
 if(HDF5_FOUND)
     add_definitions( -DUSE_HDF5 )
     include_directories( ${HDF5_INCLUDE_DIRS} )
+    foreach(HDF5_LIB ${HDF5_LIBRARIES})
+        get_filename_component( HDF5_LIB_EXT ${HDF5_LIB} EXT )
+        if( ${HDF5_LIB_EXT} STREQUAL ".a" )
+            list(APPEND STATIC_LIBRARIES ${HDF5_LIB} )
+        else( )
+            list(APPEND SYSTEM_SHARED_LIBS ${HDF5_LIB} )
+        endif( )
+    endforeach( )
 endif( HDF5_FOUND )
 
 # This is a fix for new HDF5 package on Debian/Ubuntu which installs hdf5
@@ -264,27 +258,6 @@ if(WITH_MPI)
     endif()
 endif(WITH_MPI)
 
-# Add subdirectroeis
-add_subdirectory(basecode)
-add_subdirectory(msg)
-add_subdirectory(shell)
-add_subdirectory(randnum)
-add_subdirectory(scheduling)
-add_subdirectory(biophysics)
-add_subdirectory(builtins)
-add_subdirectory(utility)
-add_subdirectory(mesh)
-add_subdirectory(mpi)
-add_subdirectory(signeur)
-add_subdirectory(ksolve)
-add_subdirectory(hsolve)
-add_subdirectory(diffusion)
-add_subdirectory(device)
-add_subdirectory(benchmarks)
-add_subdirectory(kinetics)
-add_subdirectory(synapse)
-add_subdirectory(intfire)
-
 # These are always shared libraries.
 set(SYSTEM_SHARED_LIBS ${LibXML2_LIBRARIES})
 if(WITH_BOOST)
@@ -297,15 +270,17 @@ endif(WITH_BOOST)
 # dependencies if a correct version is not found. 
 # Here we make sure that the correct static version is linked; if a correct
 # shared version is found then link the shared version in SYSTEM_SHARED_LIBS.
-
 if(WITH_GSL)
-    if(GSL_STATIC_HOME)
-        message(STATUS "Using STATIC gsl libraries: ${GSL_LIBRARIES}")
-        list(APPEND STATIC_LIBRARIES ${GSL_LIBRARIES})
-    else()
-        message(STATUS "Using system gsl : ${GSL_LIBRARIES}")
-        list(APPEND SYSTEM_SHARED_LIBS ${GSL_LIBRARIES})
-    endif()
+    message(STATUS "Using STATIC gsl libraries: ${GSL_LIBRARIES}")
+
+    foreach(GSL_LIB ${GSL_LIBRARIES} )
+        get_filename_component( GSL_LIB_EXT ${GSL_LIB} EXT )
+        if( GSL_LIB_EXT STREQUAL ".a" )
+            list(APPEND STATIC_LIBRARIES ${GSL_LIB})
+        else()
+            list(APPEND SYSTEM_SHARED_LIBS ${GSL_LIB})
+        endif( )
+    endforeach( )
 endif()
 
 if(WITH_MPI)
@@ -324,6 +299,27 @@ else()
     list(APPEND MOOSE_LIBRARIES muparser)
 endif()
 
+# Add subdirectroeis
+add_subdirectory(basecode)
+add_subdirectory(msg)
+add_subdirectory(shell)
+add_subdirectory(randnum)
+add_subdirectory(scheduling)
+add_subdirectory(biophysics)
+add_subdirectory(builtins)
+add_subdirectory(utility)
+add_subdirectory(mesh)
+add_subdirectory(mpi)
+add_subdirectory(signeur)
+add_subdirectory(ksolve)
+add_subdirectory(hsolve)
+add_subdirectory(diffusion)
+add_subdirectory(device)
+add_subdirectory(benchmarks)
+add_subdirectory(kinetics)
+add_subdirectory(synapse)
+add_subdirectory(intfire)
+
 ###################################### LINKING #################################
 list(APPEND MOOSE_LIBRARIES
     moose_builtins
@@ -354,6 +350,7 @@ if(MACOSX)
     target_link_libraries(libmoose
         "-Wl,-all_load"
         ${MOOSE_LIBRARIES}
+        ${STATIC_LIBRARIES}
         )
 
     target_link_libraries(libmoose
@@ -364,6 +361,7 @@ ELSE(MACOSX)
     target_link_libraries(libmoose 
         "-Wl,--whole-archive"
         ${MOOSE_LIBRARIES}
+        ${STATIC_LIBRARIES}
         "-Wl,--no-whole-archive"
         ${SYSTEM_SHARED_LIBS}
         )
diff --git a/moose-core/VERSION b/moose-core/VERSION
index 3087e817dc1628966069086ca1b568b49cc25cd3..4225763f8cf3bc6309bd0d3fed4f68dde69ac351 100644
--- a/moose-core/VERSION
+++ b/moose-core/VERSION
@@ -1 +1 @@
-3.1.1-38-gfeb23a0
\ No newline at end of file
+3.1.1-40-g8fe5068
\ No newline at end of file
diff --git a/moose-core/cmake_modules/FindGSL.cmake b/moose-core/cmake_modules/FindGSL.cmake
index 17260420fa97eb299391165b317f84ffd72c81bf..b33139af67aafb535cbcedd1b24452e85ea6be73 100644
--- a/moose-core/cmake_modules/FindGSL.cmake
+++ b/moose-core/cmake_modules/FindGSL.cmake
@@ -22,6 +22,7 @@
 ## --------------------------------
 ##
 
+message( STATUS "GSL_ROOT_DIR value $ENV{GSL_ROOT_DIR}")
 
 IF(WIN32)
 
@@ -48,13 +49,11 @@ IF(WIN32)
   
 ELSE(WIN32)
   IF(UNIX) 
-    SET(GSL_CONFIG_PREFER_PATH "$ENV{GSL_HOME}/bin")
-    # MESSAGE("++ DEBUG: GSL_CONFIG_PREFER_PATH: ${GSL_CONFIG_PREFER_PATH}")
-     
+    SET(GSL_CONFIG_PREFER_PATH "$ENV{GSL_ROOT_DIR}/bin")
     # GSL_CONFIG must be cleared. This script may be called again after installing
     # the proper version of gsl
-    if(EXISTS "$ENV{GSL_HOME}")
-	set(GSL_CONFIG "$ENV{GSL_HOME}/bin/gsl-config")
+    if(EXISTS "$ENV{GSL_ROOT_DIR}")
+	set(GSL_CONFIG "$ENV{GSL_ROOT_DIR}/bin/gsl-config")
 	MESSAGE(STATUS "gsl-config from environment variable: ${GSL_CONFIG}")
 	set(GSL_INCLUDE_DIRS)
         set(GSL_LIBRARIES)