diff --git a/Build.PL b/Build.PL
index ef17ec046..1c3b0e3a7 100644
--- a/Build.PL
+++ b/Build.PL
@@ -16,6 +16,8 @@ my %prereqs = qw(
     ExtUtils::MakeMaker             6.80
     ExtUtils::ParseXS               3.22
     ExtUtils::XSpp                  0
+    ExtUtils::XSpp::Cmd             0
+    ExtUtils::CppGuess              0
     ExtUtils::Typemaps              0
     ExtUtils::Typemaps::Basic       0
     File::Basename                  0
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 719bdd04e..de435813d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -241,7 +241,9 @@ if(NOT WIN32)
 endif()
 find_package(Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS system filesystem thread log locale regex)
 if(Boost_FOUND)
-#    include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
+#    message("Boost include dir: ${Boost_INCLUDE_DIRS}")
+#    message("Boost library dirs: ${Boost_LIBRARY_DIRS}")
+#    message("Boost libraries: ${Boost_LIBRARIES}")
     if (APPLE)
         # BOOST_ASIO_DISABLE_KQUEUE : prevents a Boost ASIO bug on OS X: https://svn.boost.org/trac/boost/ticket/5339
         add_definitions(-DBOOST_ASIO_DISABLE_KQUEUE)
diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt
index 572090157..ca4e63fbc 100644
--- a/deps/CMakeLists.txt
+++ b/deps/CMakeLists.txt
@@ -84,6 +84,7 @@ if (MSVC)
         dep_wxwidgets
         dep_gtest
         dep_nlopt
+        # dep_qhull # Experimental
         dep_zlib    # on Windows we still need zlib
     )
 
@@ -97,6 +98,7 @@ else()
         dep_wxwidgets
         dep_gtest
         dep_nlopt
+        dep_qhull
     )
 
 endif()
diff --git a/deps/deps-unix-common.cmake b/deps/deps-unix-common.cmake
index 3cf843f73..d6a92efcb 100644
--- a/deps/deps-unix-common.cmake
+++ b/deps/deps-unix-common.cmake
@@ -32,3 +32,16 @@ ExternalProject_Add(dep_nlopt
         -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
         ${DEP_CMAKE_OPTS}
 )
+
+find_package(Git REQUIRED)
+
+ExternalProject_Add(dep_qhull
+    EXCLUDE_FROM_ALL 1
+    URL "https://github.com/qhull/qhull/archive/v7.2.1.tar.gz"
+    URL_HASH SHA256=6fc251e0b75467e00943bfb7191e986fce0e1f8f6f0251f9c6ce5a843821ea78
+    CMAKE_ARGS
+        -DBUILD_SHARED_LIBS=OFF
+        -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
+        ${DEP_CMAKE_OPTS}
+    PATCH_COMMAND ${GIT_EXECUTABLE} apply --ignore-space-change --ignore-whitespace ${CMAKE_CURRENT_SOURCE_DIR}/qhull-mods.patch
+)
diff --git a/deps/deps-windows.cmake b/deps/deps-windows.cmake
index b3b31e5f3..041160f40 100644
--- a/deps/deps-windows.cmake
+++ b/deps/deps-windows.cmake
@@ -1,21 +1,34 @@
-
+# https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
 if (MSVC_VERSION EQUAL 1800)
+# 1800      = VS 12.0 (v120 toolset)
     set(DEP_VS_VER "12")
     set(DEP_BOOST_TOOLSET "msvc-12.0")
 elseif (MSVC_VERSION EQUAL 1900)
+# 1900      = VS 14.0 (v140 toolset)    
     set(DEP_VS_VER "14")
     set(DEP_BOOST_TOOLSET "msvc-14.0")
-elseif (MSVC_VERSION GREATER 1900)
+elseif (MSVC_VERSION LESS 1920)
+# 1910-1919 = VS 15.0 (v141 toolset)
     set(DEP_VS_VER "15")
     set(DEP_BOOST_TOOLSET "msvc-14.1")
+elseif (MSVC_VERSION LESS 1930)
+# 1920-1929 = VS 16.0 (v142 toolset)
+    set(DEP_VS_VER "16")
+    set(DEP_BOOST_TOOLSET "msvc-14.2")
 else ()
     message(FATAL_ERROR "Unsupported MSVC version")
 endif ()
 
 if (${DEPS_BITS} EQUAL 32)
     set(DEP_MSVC_GEN "Visual Studio ${DEP_VS_VER}")
+    set(DEP_PLATFORM "Win32")
 else ()
-    set(DEP_MSVC_GEN "Visual Studio ${DEP_VS_VER} Win64")
+    if (DEP_VS_VER LESS 16)
+        set(DEP_MSVC_GEN "Visual Studio ${DEP_VS_VER} Win64")
+    else ()
+        set(DEP_MSVC_GEN "Visual Studio ${DEP_VS_VER}")
+    endif ()
+    set(DEP_PLATFORM "x64")
 endif ()
 
 
@@ -28,8 +41,8 @@ endif ()
 
 ExternalProject_Add(dep_boost
     EXCLUDE_FROM_ALL 1
-    URL "https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz"
-    URL_HASH SHA256=bd0df411efd9a585e5a2212275f8762079fed8842264954675a4fddc46cfcf60
+    URL "https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.gz"
+    URL_HASH SHA256=882b48708d211a5f48e60b0124cf5863c1534cd544ecd0664bb534a4b5d506e9
     BUILD_IN_SOURCE 1
     CONFIGURE_COMMAND bootstrap.bat
     BUILD_COMMAND b2.exe
@@ -57,6 +70,7 @@ ExternalProject_Add(dep_tbb
     URL "https://github.com/wjakob/tbb/archive/a0dc9bf76d0120f917b641ed095360448cabc85b.tar.gz"
     URL_HASH SHA256=0545cb6033bd1873fcae3ea304def720a380a88292726943ae3b9b207f322efe
     CMAKE_GENERATOR "${DEP_MSVC_GEN}"
+    CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
     CMAKE_ARGS
         -DCMAKE_DEBUG_POSTFIX=_debug
         -DTBB_BUILD_SHARED=OFF
@@ -81,6 +95,7 @@ ExternalProject_Add(dep_gtest
     URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz"
     URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c
     CMAKE_GENERATOR "${DEP_MSVC_GEN}"
+    CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
     CMAKE_ARGS
         -DBUILD_GMOCK=OFF
         -Dgtest_force_shared_crt=ON
@@ -105,6 +120,7 @@ ExternalProject_Add(dep_nlopt
     URL "https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz"
     URL_HASH SHA256=c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae
     CMAKE_GENERATOR "${DEP_MSVC_GEN}"
+    CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
     CMAKE_ARGS
         -DBUILD_SHARED_LIBS=OFF
         -DNLOPT_PYTHON=OFF
@@ -133,6 +149,7 @@ ExternalProject_Add(dep_zlib
     URL "https://zlib.net/zlib-1.2.11.tar.xz"
     URL_HASH SHA256=4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066
     CMAKE_GENERATOR "${DEP_MSVC_GEN}"
+    CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
     CMAKE_ARGS
         -DSKIP_INSTALL_FILES=ON                                    # Prevent installation of man pages et al.
         "-DINSTALL_BIN_DIR=${CMAKE_CURRENT_BINARY_DIR}\\fallout"   # I found no better way of preventing zlib from creating & installing DLLs :-/
@@ -199,6 +216,33 @@ if (${DEP_DEBUG})
     )
 endif ()
 
+find_package(Git REQUIRED)
+
+ExternalProject_Add(dep_qhull
+    EXCLUDE_FROM_ALL 1
+    URL "https://github.com/qhull/qhull/archive/v7.2.1.tar.gz"
+    URL_HASH SHA256=6fc251e0b75467e00943bfb7191e986fce0e1f8f6f0251f9c6ce5a843821ea78
+    CMAKE_GENERATOR "${DEP_MSVC_GEN}"
+    CMAKE_ARGS
+        -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
+        -DBUILD_SHARED_LIBS=OFF
+        -DCMAKE_POSITION_INDEPENDENT_CODE=ON
+        -DCMAKE_DEBUG_POSTFIX=d
+    PATCH_COMMAND ${GIT_EXECUTABLE} apply --ignore-space-change --ignore-whitespace ${CMAKE_CURRENT_SOURCE_DIR}/qhull-mods.patch
+    BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
+    INSTALL_COMMAND ""
+)
+
+if (${DEP_DEBUG})
+    ExternalProject_Get_Property(dep_qhull BINARY_DIR)
+    ExternalProject_Add_Step(dep_qhull build_debug
+        DEPENDEES build
+        DEPENDERS install
+        COMMAND msbuild /m /P:Configuration=Debug INSTALL.vcxproj
+        WORKING_DIRECTORY "${BINARY_DIR}"
+    )
+endif ()
+
 
 if (${DEPS_BITS} EQUAL 32)
     set(DEP_WXWIDGETS_TARGET "")
diff --git a/deps/qhull-mods.patch b/deps/qhull-mods.patch
new file mode 100644
index 000000000..94aeeca2f
--- /dev/null
+++ b/deps/qhull-mods.patch
@@ -0,0 +1,121 @@
+From a31ae4781a4afa60e21c70e5b4ae784bcd447c8a Mon Sep 17 00:00:00 2001
+From: tamasmeszaros <meszaros.q@gmail.com>
+Date: Thu, 6 Jun 2019 15:41:43 +0200
+Subject: [PATCH] prusa-slicer changes
+
+---
+ CMakeLists.txt                     | 44 +++++++++++++++++++++++++++++++++++---
+ Config.cmake.in                    |  2 ++
+ src/libqhull_r/qhull_r-exports.def |  2 ++
+ src/libqhull_r/user_r.h            |  2 +-
+ 4 files changed, 46 insertions(+), 4 deletions(-)
+ create mode 100644 Config.cmake.in
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 59dff41..20c2ec5 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -61,7 +61,7 @@
+ # $DateTime: 2016/01/18 19:29:17 $$Author: bbarber $
+ 
+ project(qhull)
+-cmake_minimum_required(VERSION 2.6)
++cmake_minimum_required(VERSION 3.0)
+ 
+ # Define qhull_VERSION in CMakeLists.txt, Makefile, qhull-exports.def, qhull_p-exports.def, qhull_r-exports.def, qhull-warn.pri
+ set(qhull_VERSION2 "2015.2 2016/01/18")  # not used, See global.c, global_r.c, rbox.c, rbox_r.c
+@@ -610,10 +610,48 @@ add_test(NAME user_eg3
+ # Define install
+ # ---------------------------------------
+ 
+-install(TARGETS ${qhull_TARGETS_INSTALL}
++install(TARGETS ${qhull_TARGETS_INSTALL} EXPORT QhullTargets
+         RUNTIME DESTINATION ${BIN_INSTALL_DIR}
+         LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+-        ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
++        ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
++        INCLUDES DESTINATION include)
++
++include(CMakePackageConfigHelpers)
++
++write_basic_package_version_file(
++    "${CMAKE_CURRENT_BINARY_DIR}/Qhull/QhullConfigVersion.cmake"
++    VERSION ${qhull_VERSION}
++    COMPATIBILITY AnyNewerVersion
++)
++
++export(EXPORT QhullTargets
++  FILE "${CMAKE_CURRENT_BINARY_DIR}/Qhull/QhullTargets.cmake"
++  NAMESPACE Qhull::
++)
++
++configure_file(Config.cmake.in
++  "${CMAKE_CURRENT_BINARY_DIR}/Qhull/QhullConfig.cmake"
++  @ONLY
++)
++
++set(ConfigPackageLocation lib/cmake/Qhull)
++install(EXPORT QhullTargets
++  FILE
++    QhullTargets.cmake
++  NAMESPACE
++    Qhull::
++  DESTINATION
++    ${ConfigPackageLocation}
++)
++install(
++  FILES
++    "${CMAKE_CURRENT_BINARY_DIR}/Qhull/QhullConfig.cmake"
++    "${CMAKE_CURRENT_BINARY_DIR}/Qhull/QhullConfigVersion.cmake"
++  DESTINATION
++    ${ConfigPackageLocation}
++  COMPONENT
++    Devel
++)
+ 
+ install(FILES ${libqhull_HEADERS}    DESTINATION ${INCLUDE_INSTALL_DIR}/libqhull)
+ install(FILES ${libqhull_DOC}        DESTINATION ${INCLUDE_INSTALL_DIR}/libqhull)
+diff --git a/Config.cmake.in b/Config.cmake.in
+new file mode 100644
+index 0000000..bc92bfe
+--- /dev/null
++++ b/Config.cmake.in
+@@ -0,0 +1,2 @@
++include("${CMAKE_CURRENT_LIST_DIR}/QhullTargets.cmake")
++
+diff --git a/src/libqhull_r/qhull_r-exports.def b/src/libqhull_r/qhull_r-exports.def
+index 325d57c..72f6ad0 100644
+--- a/src/libqhull_r/qhull_r-exports.def
++++ b/src/libqhull_r/qhull_r-exports.def
+@@ -185,6 +185,7 @@ qh_memsetup
+ qh_memsize
+ qh_memstatistics
+ qh_memtotal
++qh_memcheck
+ qh_merge_degenredundant
+ qh_merge_nonconvex
+ qh_mergecycle
+@@ -372,6 +373,7 @@ qh_settruncate
+ qh_setunique
+ qh_setvoronoi_all
+ qh_setzero
++qh_setendpointer
+ qh_sharpnewfacets
+ qh_skipfacet
+ qh_skipfilename
+diff --git a/src/libqhull_r/user_r.h b/src/libqhull_r/user_r.h
+index fc105b9..7cca65a 100644
+--- a/src/libqhull_r/user_r.h
++++ b/src/libqhull_r/user_r.h
+@@ -139,7 +139,7 @@ Code flags --
+    REALfloat =   1      all numbers are 'float' type
+              =   0      all numbers are 'double' type
+ */
+-#define REALfloat 0
++#define REALfloat 1
+ 
+ #if (REALfloat == 1)
+ #define realT float
+-- 
+2.16.2.windows.1
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4f6959623..2f2483eca 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -17,9 +17,6 @@ add_subdirectory(semver)
 set(LIBNEST2D_UNITTESTS ON CACHE BOOL "Force generating unittests for libnest2d")
 add_subdirectory(libnest2d)
 
-include_directories(${LIBDIR}/qhull/src)
-#message(STATUS ${LIBDIR}/qhull/src)
-
 add_subdirectory(libslic3r)
 
 if (SLIC3R_GUI)
diff --git a/src/libslic3r/TriangleMesh.cpp b/src/libslic3r/TriangleMesh.cpp
index 4d35cabca..6581a8320 100644
--- a/src/libslic3r/TriangleMesh.cpp
+++ b/src/libslic3r/TriangleMesh.cpp
@@ -578,7 +578,7 @@ TriangleMesh TriangleMesh::convex_hull_3d() const
         {   // iterate through facet's vertices
 
             orgQhull::QhullPoint p = vertices[i].point();
-            const float* coords = p.coordinates();
+            const auto* coords = p.coordinates();
             dst_vertices.emplace_back(coords[0], coords[1], coords[2]);
         }
         unsigned int size = (unsigned int)dst_vertices.size();
diff --git a/src/qhull/CMakeLists.txt b/src/qhull/CMakeLists.txt
index a3e7da126..9ca0bdff2 100644
--- a/src/qhull/CMakeLists.txt
+++ b/src/qhull/CMakeLists.txt
@@ -8,6 +8,22 @@
 # Created by modification of the original qhull CMakeLists.
 # Lukas Matena (25.7.2018), lukasmatena@seznam.cz
 
+# see bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=925540
+
+find_package(Qhull 7.2 QUIET)
+
+add_library(qhull INTERFACE)
+
+if(Qhull_FOUND)
+
+message(STATUS "Using qhull from system.")
+if(SLIC3R_STATIC)
+    target_link_libraries(qhull INTERFACE Qhull::qhullcpp Qhull::qhullstatic_r)
+else()
+    target_link_libraries(qhull INTERFACE Qhull::qhullcpp Qhull::qhull_r)
+endif()
+    
+else(Qhull_FOUND)
 
 project(qhull)
 cmake_minimum_required(VERSION 2.6)
@@ -112,7 +128,7 @@ set(libqhull_SOURCES
 
 ##################################################
 # combined library (reentrant qhull and qhullcpp) for Slic3r:
-set(qhull_STATIC qhull)
+set(qhull_STATIC qhullstatic)
 add_library(${qhull_STATIC} STATIC ${libqhull_SOURCES})
 set_target_properties(${qhull_STATIC} PROPERTIES
     VERSION ${qhull_VERSION})
@@ -123,4 +139,7 @@ endif(UNIX)
 ##################################################
 
 # LIBDIR is defined in the main xs CMake file:
-target_include_directories(${qhull_STATIC} PRIVATE ${LIBDIR}/qhull/src)
+target_include_directories(${qhull_STATIC} BEFORE PUBLIC ${LIBDIR}/qhull/src)
+target_link_libraries(qhull INTERFACE ${qhull_STATIC})
+
+endif()
diff --git a/src/slic3r/Utils/Serial.cpp b/src/slic3r/Utils/Serial.cpp
index 601719b50..cd2a01cbf 100644
--- a/src/slic3r/Utils/Serial.cpp
+++ b/src/slic3r/Utils/Serial.cpp
@@ -384,7 +384,13 @@ void Serial::reset_line_num()
 
 bool Serial::read_line(unsigned timeout, std::string &line, error_code &ec)
 {
-	auto &io_service = get_io_service();
+	auto& io_service =
+#if BOOST_VERSION >= 107000
+		//FIXME this is most certainly wrong!
+		(boost::asio::io_context&)this->get_executor().context();
+ #else
+		this->get_io_service();
+#endif
 	asio::deadline_timer timer(io_service);
 	char c = 0;
 	bool fail = false;
diff --git a/xs/src/xsinit.h b/xs/src/xsinit.h
index 506ef0a0b..f14e1262d 100644
--- a/xs/src/xsinit.h
+++ b/xs/src/xsinit.h
@@ -69,7 +69,10 @@ extern "C" {
     #undef fwrite
     #undef fclose
     #undef sleep
+    #undef snprintf
+    #undef strerror
     #undef test
+    #undef times
     #undef accept
     #undef wait