diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7704c813d5892f113b90478df73696f973cf155b..e10b3f3991f9668548e9ecc5ed9200fdcc2247df 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,7 +17,7 @@ option(BORNAGAIN_APP "Build test application" OFF)
 option(BORNAGAIN_GUI "Build a graphical user interface" OFF)
 option(BORNAGAIN_MAN "Build a user manual" OFF)
 option(BUILD_DEBIAN "Build a debian package" OFF)
-option(CREATE_BUNDLE "Create a Mac OS X bundle" OFF)
+option(BORNAGAIN_APPLE_BUNDLE "Create a Mac OS X bundle" OFF)
 option(ROOT_SUPPORT "Build with dependencies from ROOT" ON)
 option(BORNAGAIN_OPENMPI "Build with OpenMPI support" OFF)
 option(BORNAGAIN_RELEASE "Special option for making release" OFF)
diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt
index c8164c7b373cd7ba26e422b573fe7789e687ac7f..37fdc3743a329bed27995ae6c90b79f209b7c3ac 100644
--- a/Core/CMakeLists.txt
+++ b/Core/CMakeLists.txt
@@ -149,22 +149,40 @@ else()
             DESTINATION ${destination_libexec})
 
     # creating bin directory for links
-    install(CODE "
-        FILE(MAKE_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
-    " COMPONENT Runtime)
-
-    # making links
-    install(CODE "
-    execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
-    \"../libexec/${destination_suffix}/frombin_setup_paths.sh\" \"thisbornagain.sh\"
-    WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
-    " COMPONENT Runtime)
-
-    install(CODE "
-    execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
-    \"../libexec/${destination_suffix}/frombin_setup_paths.csh\" \"thisbornagain.csh\"
-    WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
-    " COMPONENT Runtime)
+#    install(CODE "
+#        FILE(MAKE_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
+#    " COMPONENT Runtime)
+
+#    # making links
+#    install(CODE "
+#    execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
+#    \"../libexec/${destination_suffix}/frombin_setup_paths.sh\" \"thisbornagain.sh\"
+#    WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
+#    " COMPONENT Runtime)
+
+#    install(CODE "
+#    execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
+#    \"../libexec/${destination_suffix}/frombin_setup_paths.csh\" \"thisbornagain.csh\"
+#    WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
+#    " COMPONENT Runtime)
+
+#    install(CODE "
+#        FILE(MAKE_DIRECTORY \"${destination_bin}\")
+#    " COMPONENT Runtime)
+
+#    # making links
+#    install(CODE "
+#    execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
+#    \"../libexec/${destination_suffix}/frombin_setup_paths.sh\" \"thisbornagain.sh\"
+#    WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
+#    " COMPONENT Runtime)
+
+#    install(CODE "
+#    execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
+#    \"../libexec/${destination_suffix}/frombin_setup_paths.csh\" \"thisbornagain.csh\"
+#    WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
+#    " COMPONENT Runtime)
+
 
 endif()
 
diff --git a/GUI/coregui/CMakeLists.txt b/GUI/coregui/CMakeLists.txt
index 8f0edabe58731cf9f9696aa575d0f2df511b4a9c..f28f80711e21af92d8a8687f7a51a87400e295b3 100644
--- a/GUI/coregui/CMakeLists.txt
+++ b/GUI/coregui/CMakeLists.txt
@@ -129,7 +129,7 @@ target_link_libraries(${library_name}
     ${ManhattanStyle_LIBRARY}
     ${qcustomplot_LIBRARY}
     ${qtpropertybrowser_LIBRARY}
-    ${PYTHON_LIBRARY} 
+    ${PYTHON_LIBRARIES}
     ${Boost_LIBRARIES}
     ${BornAgainCore_LIBRARY}
     ${BornAgainFit_LIBRARY}
diff --git a/GUI/main/CMakeLists.txt b/GUI/main/CMakeLists.txt
index 55adc4d6cc394aa5cee5d7667c6911aeb63dfdb5..5e07eec9cb26ea797ac112d348142fcde6597156 100644
--- a/GUI/main/CMakeLists.txt
+++ b/GUI/main/CMakeLists.txt
@@ -59,7 +59,7 @@ target_link_libraries(${executable_name}
     ${ManhattanStyle_LIBRARY}
     ${qcustomplot_LIBRARY}
     ${qtpropertybrowser_LIBRARY}
-    ${PYTHON_LIBRARY}
+    ${PYTHON_LIBRARIES}
     ${Boost_LIBRARIES}
     ${BornAgainCore_LIBRARY}
     ${BornAgainFit_LIBRARY}
@@ -94,21 +94,17 @@ elseif(APPLE)
             MACOSX_BUNDLE_INFO_PLIST ${destination_runtime_configs}/Info.plist
     )
 
-#install ( FILES ${CMAKE_SOURCE_DIR}/GUI/main/BornAgain.icns
-#          DESTINATION ${INBUNDLE}/Contents/Resources/
-#)
-
-##set ( CPACK_DMG_BACKGROUND_IMAGE ${CMAKE_SOURCE_DIR}/Images/osx-bundle-background.png )
-##set ( CPACK_DMG_DS_STORE ${CMAKE_SOURCE_DIR}/Installers/MacInstaller/osx_DS_Store)
-#set ( MACOSX_BUNDLE_ICON_FILE BornAgain.icns )
-#SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/GUI/main/BornAgain.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
-
+    set(link_flags "-Wl,-rpath,@loader_path/../")
+    set_target_properties(${executable_name}
+        PROPERTIES
+        LINK_FLAGS ${link_flags}
+    )
 
 endif()
 
 # --- installation ---------
 #install (TARGETS ${executable_name} DESTINATION ${destination_gui} COMPONENT Applications)
-install (TARGETS ${executable_name} BUNDLE DESTINATION . RUNTIME DESTINATION ${destination_gui} COMPONENT Applications)
+install (TARGETS ${executable_name} BUNDLE DESTINATION . COMPONENT Applications)
 
 #  install (TARGETS ${executable_name}
 #    BUNDLE DESTINATION  . COMPONENT Applications
@@ -119,13 +115,26 @@ set(image_files ${CMAKE_SOURCE_DIR}/GUI/main/BornAgain.ico ${CMAKE_SOURCE_DIR}/G
 install (FILES ${image_files} DESTINATION ${destination_images} COMPONENT Applications)
 
 
+# --- system dependent installation ---------
 if(WIN32)
 
-elseif(APPLE)
+elseif(APPLE AND BORNAGAIN_APPLE_BUNDLE)
     install( FILES ${CMAKE_SOURCE_DIR}/GUI/main/BornAgain.icns
           DESTINATION ${destination_bundle}/Contents/Resources/
     )
 
+    set(plugin_dest_dir ${destination_bundle}/Contents/PlugIns)
+    install(DIRECTORY "$ENV{QTDIR}/plugins/platforms" DESTINATION ${plugin_dest_dir} COMPONENT Runtime)
+
+    set(fixup_path @rpath)
+    configure_file(${CMAKE_SOURCE_DIR}/cmake/modules/FixAppleBundle.cmake.in ${destination_runtime_configs}/FixAppleBundle.cmake @ONLY)
+    install(SCRIPT ${destination_runtime_configs}/FixAppleBundle.cmake COMPONENT Runtime)
+
+#  get_filename_component(PYTHON_REAL_LIBRARY "${PYTHON_LIBRARY}" REALPATH)
+#  add_library(Python SHARED IMPORTED)
+#  set_property(TARGET Python PROPERTY IMPORTED_LOCATION ${PYTHON_LIBRARY})
+#    message("XXXXXX PYTHON_LIBRARY:${PYTHON_LIBRARY} PYTHON_REAL_LIBRARY:${PYTHON_REAL_LIBRARY}  PYTHON_LIBRARIES:${PYTHON_LIBRARIES}")
+
 
 endif()
 
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 6b74f93a9e1b4b99d3ea3d8f119b5a809636fb17..df9b9904522ae78f726da96bde3a17e50cd958fa 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -1,6 +1,6 @@
 # this script is a trick to print the message at the end of installation
 
-if(NOT WIN32 AND NOT CREATE_BUNDLE)
+if(NOT WIN32 AND NOT BORNAGAIN_APPLE_BUNDLE)
 set(after_install_text "
 Installation done. Please read below.
 -------------------------------------------------------------------------------
diff --git a/cmake/modules/FixBundle.cmake.in b/cmake/modules/FixAppleBundle.cmake.in
similarity index 81%
rename from cmake/modules/FixBundle.cmake.in
rename to cmake/modules/FixAppleBundle.cmake.in
index 5fc3195bf25a4af687962967d8efd41d42c32bf9..562fa112542bd800baf607318ba0cc51730c3229 100644
--- a/cmake/modules/FixBundle.cmake.in
+++ b/cmake/modules/FixAppleBundle.cmake.in
@@ -1,5 +1,8 @@
 
-set ( bundle ${CMAKE_INSTALL_PREFIX}/BornAgain.app )
+set(bundle ${CMAKE_INSTALL_PREFIX}/BornAgain.app )
+set(bornagain_libs ${CMAKE_INSTALL_PREFIX}/@destination_lib@)
+set(thirdparty_libs ${CMAKE_INSTALL_PREFIX}/@destination_lib@)
+
 
 #set(GP_RPATH_DIR ${bundle}/Contents)
 set(BU_CHMOD_BUNDLE_ITEMS True)
@@ -28,17 +31,13 @@ function(gp_resolved_file_type_override resolved_file type_var)
         set(${type_var} embedded PARENT_SCOPE)
 
     elseif(item MATCHES "PlugIns/platforms")
-        message("XXX  resolving file as _embedded : ${file}")
+        message("XXX3  resolving file as _embedded : ${file}")
         set(${type_var} embedded PARENT_SCOPE)
 
-    elseif(file MATCHES "Python.framework/Resources")
-        message("XXX  resolving file as _embedded : ${file}")
+    elseif(file MATCHES "Python.framework")
+        message("XXX  resolving file as system : ${file}")
         set(${type_var} system PARENT_SCOPE)
 
-    elseif(file MATCHES "Python.framework/Versions")
-        message("XXX  resolving file as _embedded : ${file}")
-        set(${type_var} embedded PARENT_SCOPE)
-
     elseif(file MATCHES "/opt")
         message("XXX  resolving file as _embedded : ${file}")
         set(${type_var} embedded PARENT_SCOPE)
@@ -163,6 +162,7 @@ message("QQQQ QTPLUGINS ${QTPLUGINS} dirs ${dirs}")
 
 fixup_bundle ( "${bundle}" "${other_libs}" "${dirs}" ) # This will fix up the dependencies for the hard dependencies: MantidKernel etc
 
+
 ####################################################
 # Functions to change the dependency references
 ####################################################
@@ -174,3 +174,30 @@ function( change_bundle_dep old_dep new_dep sharedlib )
   execute_process(COMMAND install_name_tool -change ${old_dep} ${new_dep} ${sharedlib})
 endfunction()
 
+
+function(fix_python_framework items_to_fix)
+    foreach(item ${items_to_fix})
+        message("XXXXXXXX -> fixing item ${item}")
+        get_prerequisites(${item} prereqs 0 0 "" "")
+        foreach(pr ${prereqs})
+            if(pr MATCHES "Python.framework")
+                message("XXXXXXXX ${pr}")
+                change_bundle_dep( ${pr} "@rpath/lib/ThirdParty/libpython2.7.dylib" ${item})
+            endif()
+        endforeach()
+    endforeach()
+endfunction()
+
+
+set(items_to_fix "${bundle}/Contents/MacOs/BornAgain")
+file (GLOB items ${bornagain_libs}/*.so)
+list(APPEND items_to_fix ${items})
+file (GLOB items ${bundle}/Contents/lib/ThirdParty/*.dylib)
+list(APPEND items_to_fix ${items})
+
+message("AAA ${items_to_fix}")
+
+fix_python_framework("${items_to_fix}")
+
+message("Copying library @PYTHON_LIBRARIES@")
+execute_process(COMMAND ${CMAKE_COMMAND} -E copy "@PYTHON_LIBRARIES@" "${bundle}/Contents/lib/ThirdParty/libpython2.7.dylib")
diff --git a/cmake/modules/bundle.cmake.in b/cmake/modules/bundle.cmake.in
deleted file mode 100644
index 96d72efd31296a655d57d039de9313a91ecb813d..0000000000000000000000000000000000000000
--- a/cmake/modules/bundle.cmake.in
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-message(STATUS "aaaa @INBUNDLE@")
-
-set(BU_CHMOD_BUNDLE_ITEMS True)
-set(BU_COPY_FULL_FRAMEWORK_CONTENTS False)
-
-set(plugin_dest_dir @INBUNDLE@/Contents/PlugIns)
-set(qtconf_dest_dir @INBUNDLE@/Contents/Resources)
-set(APPS @CMAKE_INSTALL_PREFIX@/@INBUNDLE@)
-
-
-file(GLOB_RECURSE QTPLUGINS "@CMAKE_INSTALL_PREFIX@/${plugin_dest_dir}/*@CMAKE_SHARED_LIBRARY_SUFFIX@")
-message("AAAAA QTPLUGINS ${QTPLUGINS}")
-message("AAAAA QTPLUGINS ${QTPLUGINS}")
-
-include(BundleUtilities)
-fixup_bundle(${APPS} "${QTPLUGINS}" "@DIRS@")
-