diff --git a/Makefile b/Makefile
index 16d97c0a..80e42f3c 100644
--- a/Makefile
+++ b/Makefile
@@ -63,7 +63,7 @@ endif
 endif
 
 export LDFLAGS= -pthread -lm $(ADD_LDFLAGS) $(DMLC_LDFLAGS)
-export CFLAGS= -DDMLC_LOG_CUSTOMIZE=1 -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude $(ADD_CFLAGS)
+export CFLAGS= -DDMLC_LOG_CUSTOMIZE=1 -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude
 CFLAGS += -I$(DMLC_CORE)/include -I$(RABIT)/include -I$(GTEST_PATH)/include
 #java include path
 export JAVAINCFLAGS = -I${JAVA_HOME}/include -I./java
@@ -111,6 +111,10 @@ else
 endif
 CFLAGS += $(OPENMP_FLAGS)
 
+# Add the ADD_*FLAGS last so they take precedence
+LDFLAGS += $(ADD_LDFLAGS)
+CFLAGS += $(ADD_CFLAGS)
+
 # specify tensor path
 .PHONY: clean all lint clean_all doxygen rcpplint pypack Rpack Rbuild Rcheck java pylint
 
diff --git a/python-package/setup.py b/python-package/setup.py
index a2146f6b..c94b7819 100644
--- a/python-package/setup.py
+++ b/python-package/setup.py
@@ -5,6 +5,7 @@ import io
 import sys
 import os
 from setuptools import setup, find_packages
+import shutil
 
 # import subprocess
 sys.path.insert(0, '.')
@@ -27,7 +28,14 @@ for libfile in libpath['find_lib_path']():
     except ValueError:
         continue
 
-print("Install libxgboost from: %s" % LIB_PATH)
+if os.getenv('CONDA_BUILD'):
+    print("Conda-build detected, not installing (xgboost nor) libxgboost from: %s" % LIB_PATH)
+    data_files=('xgboost')
+else:
+    print("Install libxgboost from: %s" % LIB_PATH)
+    data_files=('xgboost', LIB_PATH)
+
+shutil.copy(os.path.join(os.environ['SRC_DIR'], 'dmlc-core/tracker/dmlc_tracker/tracker.py'), 'xgboost/tracker.py')
 
 # Please use setup_pip.py for generating and deploying pip installation
 # detailed instruction in setup_pip.py
@@ -53,7 +61,7 @@ setup(name='xgboost',
       # this will use MANIFEST.in during install where we specify additional files,
       # this is the golden line
       include_package_data=True,
-      data_files=[('xgboost', LIB_PATH)],
+      data_files=[data_files],
       license='Apache-2.0',
       classifiers=['License :: OSI Approved :: Apache Software License',
                    'Development Status :: 5 - Production/Stable',
diff --git a/python-package/xgboost/libpath.py b/python-package/xgboost/libpath.py
index a313a1b8..cd7e1dee 100644
--- a/python-package/xgboost/libpath.py
+++ b/python-package/xgboost/libpath.py
@@ -23,6 +23,10 @@ def find_lib_path():
     dll_path = [curr_path, os.path.join(curr_path, '../../lib/'),
                 os.path.join(curr_path, './lib/'),
                 os.path.join(sys.prefix, 'xgboost')]
+    if sys.platform == 'win32':
+        dll_path = [os.path.join(sys.prefix, 'Library', 'mingw-w64', 'bin')]
+    else:
+        dll_path = [os.path.join(sys.prefix, 'lib')]
     if sys.platform == 'win32':
         if platform.architecture()[0] == '64bit':
             dll_path.append(os.path.join(curr_path, '../../windows/x64/Release/'))
