diff --git a/JPSvis.pro b/JPSvis.pro
index 7ce3134a5c24a94d618f2744b60461380553bbe6..924daac5dcaee8834f1fc9c071b0eb6ada7be40b 100644
--- a/JPSvis.pro
+++ b/JPSvis.pro
@@ -370,7 +370,7 @@ unix_6 {
 }
    
 #dynamic linking with vtk5.8
-unix{
+unix: !macx{
 INCLUDEPATH += /usr/include/vtk-5.8
 LIBS += -L/usr/lib \
     -lvtkRendering  \
@@ -435,7 +435,11 @@ unix_static {
     -ldl \
  }
 
-macx{
+macx {
+#CONFIG += objective_c
+LIBS += -framework Cocoa
+QMAKE_MAC_SDK = macosx10.9
+        QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.8
         INCLUDEPATH += /Users/piccolo/VTK/include/vtk-6.1
         LIBS += -L/Users/piccolo/VTK/lib \
             -lvtkalglib-6.1  \
@@ -554,6 +558,8 @@ macx{
             -lvtkzlib-6.1  \
 }
 
+OBJECTIVE_SOURCES += src/fix/osx_thread_fix.mm
+
 HEADERS += src/geometry/Building.h \
     src/geometry/Crossing.h \
     src/geometry/Goal.h \
@@ -594,7 +600,8 @@ HEADERS += src/geometry/Building.h \
     src/geometry/PointPlotter2D.h \
     src/network/TraVisToServer.h \
     src/MainWindow.h \
-    src/TrailPlotter.h
+    src/TrailPlotter.h  \
+    src/fix/osx_thread_fix.mm
 
 SOURCES += src/geometry/Building.cpp \
     src/geometry/Crossing.cpp \
diff --git a/src/IO/OutputHandler.cpp b/src/IO/OutputHandler.cpp
index 96d35698bb1083af9c3245af31ec8ba216164ab0..064c973771c78b59dfe2abce76a9e000222c52c9 100644
--- a/src/IO/OutputHandler.cpp
+++ b/src/IO/OutputHandler.cpp
@@ -31,6 +31,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <cstdlib>
+#include <cmath>
 
 using namespace std;
 
diff --git a/src/InteractorStyle.cpp b/src/InteractorStyle.cpp
index 822824dbe31adeef1a1b31b9b484dfd876bc4a41..f445a20e432d84f3382113a180b15a216eff09ca 100644
--- a/src/InteractorStyle.cpp
+++ b/src/InteractorStyle.cpp
@@ -68,12 +68,11 @@ InteractorStyle* InteractorStyle::New()
 void InteractorStyle::SetActor()
 {
 }
-;
+
 
 void InteractorStyle::SetSource()
 {
 }
-;
 
 //forward the event only if not in 2d mode
 void InteractorStyle::Rotate()
diff --git a/src/InteractorStyle.h b/src/InteractorStyle.h
index a780fad5eeef8bed63c2256fc6686879c42c9251..ab0b6ca134ea3b95ded0e04d6b19b46653380230 100644
--- a/src/InteractorStyle.h
+++ b/src/InteractorStyle.h
@@ -62,8 +62,6 @@ public:
     virtual void OnMouseMove();
 
 
-
-
 private:
     //vtkActor* mActor ;
     //vtkSphereSource* mSrc ;
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index b2556f9f59213ee0c75529b99e0875dd81663821..dbca30e1555c077a43676da67e4f02f18fd6d673 100755
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -63,8 +63,6 @@
 #include <QtXml>
 #include <QTemporaryFile>
 
-
-
 #include <iostream>
 #include <limits>
 #include <string>
@@ -72,6 +70,25 @@
 
 using namespace std;
 
+
+#ifdef __APPLE__
+#include <thread>
+#include <dispatch/dispatch.h>
+#include "fix/osx_thread_fix.h"
+
+std::thread::id main_thread_id = std::this_thread::get_id();
+dispatch_queue_t main_q = dispatch_get_main_queue();
+
+void is_main_thread() {
+
+    if ( main_thread_id == std::this_thread::get_id() )
+        std::cout << "This is the main thread.\n";
+    else
+        std::cout << "This is not the main thread.\n";
+}
+#endif
+
+
 MainWindow::MainWindow(QWidget *parent) :
     QMainWindow(parent)
 {
@@ -199,7 +216,7 @@ MainWindow::MainWindow(QWidget *parent) :
                     bool ok=false;
                     int port = arguments[++argCount].toInt(&ok);
                     Debug::
-                    Debug::Messages(" listening port: %d",port);
+                            Debug::Messages(" listening port: %d",port);
 
                     if (ok) {
                         SystemSettings::setListeningPort(port);
@@ -234,20 +251,20 @@ MainWindow::~MainWindow()
     extern_recording_enable=false;
 
     //save all settings for the next session
-     if(ui.actionRemember_Settings->isChecked())
-     {
-          saveAllSettings();
-           qDebug()<<"saving all settings";
-     }
-     else
-     {
-         //first clear everyting
-         QSettings settings;
-         settings.clear();
-         //then remember that we do not want any settings saved
-         settings.setValue("options/rememberSettings", false);
-         qDebug()<<"clearing all settings";
-     }
+    if(ui.actionRemember_Settings->isChecked())
+    {
+        saveAllSettings();
+        qDebug()<<"saving all settings";
+    }
+    else
+    {
+        //first clear everyting
+        QSettings settings;
+        settings.clear();
+        //then remember that we do not want any settings saved
+        settings.setValue("options/rememberSettings", false);
+        qDebug()<<"clearing all settings";
+    }
 
 
     if (visualisationThread->isRunning()) {
@@ -273,16 +290,16 @@ MainWindow::~MainWindow()
 void MainWindow::slotHelpAbout()
 {
     QMessageBox::about(
-        this,
-        "About JPSVis",
-        "Version 0.6 built with  QT 4.8 and VTK 5.10\n\n"
-        "JPSvis is part of the Juelich Pedestrian Simulator (JuPedsim)"
-        "It is a tool for visualizing pedestrians motion\n"
-        "developped at the Forschungszentrum Juelich GmbH, Germany\n\n"
-        "Copyright 2009-2014.\n"
-        "Authors: Ulrich Kemloh\n\n"
-        "For questions, contact +49-40-246161-4193 \nor mail at \n"
-        "u.kemloh@fz-juelich.de\n");
+                this,
+                "About JPSVis",
+                "Version 0.6 built with  QT 4.8 and VTK 5.10\n\n"
+                "JPSvis is part of the Juelich Pedestrian Simulator (JuPedsim)"
+                "It is a tool for visualizing pedestrians motion\n"
+                "developped at the Forschungszentrum Juelich GmbH, Germany\n\n"
+                "Copyright 2009-2014.\n"
+                "Authors: Ulrich Kemloh\n\n"
+                "For questions, contact +49-40-246161-4193 \nor mail at \n"
+                "u.kemloh@fz-juelich.de\n");
 }
 
 
@@ -320,10 +337,29 @@ void MainWindow::slotStartPlaying()
             } else if (!slotAddDataSet()) { //else load a dataset
                 return;//could not read any data
             }
+#ifdef __APPLE__
+            //std::thread::id main_thread_id = std::this_thread::get_id();
+            dispatch_queue_t main_q = dispatch_get_main_queue();
+            dispatch_async(main_q, ^(void){
+                               //visualisationThread->moveToThread(QApplication::instance()->thread());
+                               visualisationThread->run();
+                           });
+#elif
             visualisationThread->start();
 
+#endif
+
         } else { /*if (extern_online_mode)*/  //live visualisation
+
+#ifdef __APPLE__
+            dispatch_async(main_q, ^(void){
+                               dataTransferThread->run();
+                           });
+#elif
             dataTransferThread->start();
+
+#endif
+            //dataTransferThread->start();
             //visualisationThread->start();
         }
 
@@ -453,27 +489,27 @@ FacilityGeometry* MainWindow::parseGeometry(QDomNode geoNode)
 FacilityGeometry* MainWindow::parseGeometry(QString geometryString)
 {
 
-//    QDomDocument doc("");
-//    data = "<travisto>\n" +data+ "\n</travisto>\n";
+    //    QDomDocument doc("");
+    //    data = "<travisto>\n" +data+ "\n</travisto>\n";
 
-//    QString errorMsg="";
-//    doc.setContent(data,&errorMsg);
+    //    QString errorMsg="";
+    //    doc.setContent(data,&errorMsg);
 
-//    if(!errorMsg.isEmpty()){
-//        Debug::Error("%s", (const char *)errorMsg.toStdString().c_str());
-//        return;
-//    }
+    //    if(!errorMsg.isEmpty()){
+    //        Debug::Error("%s", (const char *)errorMsg.toStdString().c_str());
+    //        return;
+    //    }
 
-//    QDomNode geoNode =doc.elementsByTagName("geometry").item(0);
+    //    QDomNode geoNode =doc.elementsByTagName("geometry").item(0);
 
     //create a temporary file with the content geonode
 
-//    QTemporaryFile file;
-//    file.setFileName(file.fileName()+".xml");
-//    if (file.open()) {
-//        QTextStream stream(&file);
-//        stream << geoNode << endl;
-//    }
+    //    QTemporaryFile file;
+    //    file.setFileName(file.fileName()+".xml");
+    //    if (file.open()) {
+    //        QTextStream stream(&file);
+    //        stream << geoNode << endl;
+    //    }
 
     QFile file("_geometry_tmp_file.xml");
     if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
@@ -743,7 +779,7 @@ void MainWindow::slotRecord()
 }
 
 QString MainWindow::getTagValueFromElement(QDomNode node,
-        const char * tagName)
+                                           const char * tagName)
 {
     if (node.isNull())
         return "";
@@ -855,7 +891,7 @@ void MainWindow::slotFrameNumber(unsigned long actualFrameCount)
     }
 
     if(!frameSliderHold)if(maxFrameCount!=0)//TODO WTF, otherwise an arrymtic exeption arises
-            ui.framesIndicatorSlider->setValue((ui.framesIndicatorSlider->maximum()*actualFrameCount)/maxFrameCount);
+        ui.framesIndicatorSlider->setValue((ui.framesIndicatorSlider->maximum()*actualFrameCount)/maxFrameCount);
 }
 
 void MainWindow::slotRunningTime(unsigned long timems)
diff --git a/src/ThreadVisualisation.cpp b/src/ThreadVisualisation.cpp
index f14586f7f7d5471b272ab5b1882b0ac47bd502fb..129bff8a2e8cf53d3b324c4469af57820f7a73f1 100644
--- a/src/ThreadVisualisation.cpp
+++ b/src/ThreadVisualisation.cpp
@@ -90,7 +90,22 @@
 #include "geometry/PointPlotter.h"
 #include "Debug.h"
 
-//#include <vector>
+#ifndef __APPLE__
+#include <thread>
+#include <dispatch/dispatch.h>
+#include "fix/osx_thread_fix.h"
+
+std::thread::id main_thread_id = std::this_thread::get_id();
+dispatch_queue_t main_q = dispatch_get_main_queue();
+
+void is_main_thread() {
+    if ( main_thread_id == std::this_thread::get_id() )
+        std::cout << "This is the main thread.\n";
+    else
+        std::cout << "This is not the main thread.\n";
+}
+
+#endif
 
 #define VTK_CREATE(type, name) \
     vtkSmartPointer<type> name = vtkSmartPointer<type>::New()
@@ -147,6 +162,7 @@ void ThreadVisualisation::run()
 
     //emit signalStatusMessage("running");
 
+
     // Create the renderer
     renderer = vtkRenderer::New();
     // set the background
@@ -264,7 +280,7 @@ void ThreadVisualisation::run()
 
     //CAUTION: this is necessary for WIN32 to update the window name
     // but his will freeze your system on linux
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__APPLE__)
     renderWindow->Render();
 #endif
 
@@ -288,7 +304,7 @@ void ThreadVisualisation::run()
     }
 
 
-    if(true || SystemSettings::get2D()) {
+    if(false || SystemSettings::get2D()) {
         renderer->GetActiveCamera()->OrthogonalizeViewUp();
         renderer->GetActiveCamera()->ParallelProjectionOn();
         renderer->ResetCamera();
@@ -355,24 +371,38 @@ void ThreadVisualisation::run()
     setNavLinesColor(SystemSettings::getNavLinesColor());
 
 
-    renderWinInteractor->Start();
 
 
+
+#ifdef __APPLE__
+//InitMultiThreading();
+
+//dispatch_async(main_q, ^(void){
+//          is_main_thread(); //Unfortunately not
+//          std::cout << "now spinning the visualizer" << std::endl;
+                  renderWinInteractor->Start();
+
+//});
+    //[[NSThread new] start];
+    //#include <objc/objc.h>
+    //NSThread* myThread = [[NSThread alloc] initWithTarget:self selector:@selector(workerThreadFunction:) object:nil];
+    //[myThread start];
+#endif
     //emit signalStatusMessage("Idle");
     emit signal_controlSequences("CONTROL_RESET");
 
 
     //clear some stuffs
-    delete extern_trail_plotter;
-    finalize();
+    //delete extern_trail_plotter;
+    //finalize();
 
-    renderer->Delete();
-    renderWindow->Delete();
-    renderWinInteractor->Delete();
-    _topViewCamera->Delete();
-    renderer=NULL;
+    //renderer->Delete();
+    //renderWindow->Delete();
+    //renderWinInteractor->Delete();
+    //_topViewCamera->Delete();
+    //renderer=NULL;
 
-    delete renderingTimer;
+    //delete renderingTimer;
 
 }
 
diff --git a/src/fix/osx_thread_fix.h b/src/fix/osx_thread_fix.h
new file mode 100644
index 0000000000000000000000000000000000000000..81d107160c3fe8651b0f298f27d4e04f478b5b52
--- /dev/null
+++ b/src/fix/osx_thread_fix.h
@@ -0,0 +1,7 @@
+#ifndef OSX_THREAD_FIX_H
+#define OSX_THREAD_FIX_H
+
+void InitMultiThreading();
+
+#endif // OSX_THREAD_FIX_H
+
diff --git a/src/fix/osx_thread_fix.mm b/src/fix/osx_thread_fix.mm
new file mode 100644
index 0000000000000000000000000000000000000000..7f481a4783ec3559c4443ac5f877f4515f4cf298
--- /dev/null
+++ b/src/fix/osx_thread_fix.mm
@@ -0,0 +1,38 @@
+
+#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
+#import "osx_thread_fix.h"
+
+
+@interface CocoaMultithreading : NSObject
++ (void)beginMultithreading;
+@end
+
+@implementation CocoaMultithreading
++ (void)dummyThread:(id)unused
+{
+    (void)unused;
+}
+
++ (void)beginMultithreading
+{
+    [NSThread detachNewThreadSelector:@selector(dummyThread:)
+            toTarget:self withObject:nil];
+}
+@end
+
+
+void InitMultiThreading()
+{
+    [[NSThread new] start];
+    NSString *msg = @"Starting multithreading";
+    NSLog(@"%@", msg);
+    //NSLog(@"%@", isMultiThreaded);
+    [CocoaMultithreading beginMultithreading];
+
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    //Do stuff
+    [pool release];
+}
+
+
diff --git a/src/general/Macros.h b/src/general/Macros.h
index fca874fa65a331ae4aebb3c9a248f45699e0706b..c8d457c63fd6d882af2f3d0a3beb82d810f3c622 100644
--- a/src/general/Macros.h
+++ b/src/general/Macros.h
@@ -38,8 +38,6 @@
 #include <sstream>
 
 #ifndef M_PI
-#define _USE_MATH_DEFINES
-#include <math.h>
 #define M_PI   3.14159265358979323846
 #endif
 
diff --git a/src/main.cpp b/src/main.cpp
index 3897a4c4eab663df54677b64431f7dd1df73d701..85aea743626c40aced70a942f855507e8e7dec8a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -53,6 +53,7 @@
 #undef VTK_USE_FFMPEG
 
 #include "MainWindow.h"
+#include "fix/osx_thread_fix.h"
 
 #include <QApplication>
 #include <QDir>
@@ -63,6 +64,9 @@
 
 int main(int argc, char *argv[])
 {
+
+    InitMultiThreading();
+
     QApplication a(argc, argv);
     // To ensure that decimal numbers use a "point" instead of "colon" on some systems
     //setlocale(LC_NUMERIC, "en_US" );
@@ -73,6 +77,8 @@ int main(int argc, char *argv[])
                      + QDir::separator()
                      + "lib");
 
+
+
     MainWindow w;
     w.show();
     return a.exec();