diff --git a/src/IO/OutputHandler.cpp b/src/IO/OutputHandler.cpp
index 8f57384657cbd5be79eb6ca0c3b7a300fadd073a..96d35698bb1083af9c3245af31ec8ba216164ab0 100644
--- a/src/IO/OutputHandler.cpp
+++ b/src/IO/OutputHandler.cpp
@@ -1,13 +1,14 @@
 /**
- * File:   OutputHandler.cpp
+ * \file        OutputHandler.cpp
+ * \date        Nov 20, 2010
+ * \version     v0.6
+ * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
- * Created on 20. November 2010, 15:20
- *
- * @section LICENSE
+ * \section License
  * This file is part of JuPedSim.
  *
  * JuPedSim is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * it under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
  * any later version.
  *
@@ -16,14 +17,14 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Lesser General Public License
  * along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
  *
- * @section DESCRIPTION
- *
+ * \section Description
  *
  *
- */
+ **/
+
 
 #include "OutputHandler.h"
 
@@ -33,105 +34,193 @@
 
 using namespace std;
 
+void OutputHandler::incrementWarnings()
+{
+     _nWarnings += 1;
+}
+
+int OutputHandler::GetWarnings()
+{
+     return _nWarnings;
+}
 
-void OutputHandler::Write(string str)
+void OutputHandler::incrementErrors()
 {
-    if (this != NULL)
-        cout << str << endl;
+     _nErrors += 1;
 }
 
-void OutputHandler::Write(const char* message,...)
+int OutputHandler::GetErrors()
 {
-    char msg[CLENGTH];
+     return _nErrors;
+}
+
+void OutputHandler::Write(const string& str)
+{
+     if (this != NULL)
+          cout << str << endl;
+}
+
+void OutputHandler::ProgressBar(double TotalPeds, double NowPeds)
+{
+     // based on this answer:
+     // https://stackoverflow.com/questions/1637587/c-libcurl-console-progress-bar
+     // how wide you want the progress meter to be
+     int totaldotz=40;
+     double fraction = NowPeds / TotalPeds;
+     // part of the progressmeter that's already "full"
+     int dotz = round(fraction * totaldotz);
+
+     // create the "meter"
+     int ii=0;
+     printf("Evacuation: %3.0f%% [",fraction*100);
+     // part  that's full already
+     for ( ; ii < dotz; ii++) {
+          printf("=");
+     }
+     printf(">");
+     // remaining part (spaces)
+     for ( ; ii < totaldotz;ii++) {
+          printf(" ");
+     }
+     // and back to line begin - do not forget the fflush to avoid output buffering problems!
+     printf("]\r");
+     fflush(stdout);
+}
+
+void OutputHandler::Write(const char* message,...)
+ {
+    char msg[CLENGTH]="";
     va_list ap;
-    va_start (ap, message);
-    vsprintf (msg,message ,ap);
-    va_end (ap);
+    va_start(ap, message);
+    vsprintf(msg, message, ap);
+    va_end(ap);
 
     string str(msg);
-    if(str.find("ERROR")==string::npos) {
-        cout<<msg<<endl;
-        cout.flush();
-    } else {
-        cerr<<msg<<endl;
+
+    if (str.find("ERROR") != string::npos)
+    {
+        cerr << msg << endl;
         cerr.flush();
+        incrementErrors();
+    }
+    else if (str.find("WARNING") != string::npos)
+    {
+        cerr << msg << endl;
+        cerr.flush();
+        incrementWarnings();
+    }
+    else
+    { // infos
+        cout << msg << endl;
+        cout.flush();
     }
-
-    //cout << "\033[1;30mbold red text\033[0m\n";
-    //cout << "\033[1;31"<<msg<<"\033[0m\n";
-    //cout << "\033[1;31 bla bla \033[0m\n";
 }
 
-void STDIOHandler::Write(string str)
+void STDIOHandler::Write(const string& str)
 {
-    if (this != NULL)
-        cout << str << endl;
+    if (str.find("ERROR") != string::npos)
+       {
+           cerr << str << endl;
+           cerr.flush();
+           incrementErrors();
+       }
+       else if (str.find("WARNING") != string::npos)
+       {
+           cerr << str << endl;
+           cerr.flush();
+           incrementWarnings();
+       }
+       else
+       { // infos
+           cout << str << endl;
+           cout.flush();
+       }
 }
 
 FileHandler::FileHandler(const char *fn)
 {
-    pfp.open(fn);
-    if (!fn) {
-        char tmp[CLENGTH];
-        sprintf(tmp, "Error!!! File [%s] could not be opened!", fn);
-        cerr << tmp << endl;
-        exit(0);
-    }
+     _pfp.open(fn);
+     if (!_pfp.is_open())
+     {
+          char tmp[CLENGTH];
+          sprintf(tmp, "Error!!! File [%s] could not be opened!", fn);
+          cerr << tmp << endl;
+          exit(0);
+     }
 }
 
 FileHandler::~FileHandler()
 {
-    pfp.close();
+     _pfp.close();
 }
 
-void FileHandler::Write(string str)
+void FileHandler::Write(const string& str)
 {
     if (this != NULL) {
-        pfp << str << endl;
-        pfp.flush();
+        _pfp << str << endl;
+        _pfp.flush();
+    }
+
+    if (str.find("ERROR") != string::npos)
+    {
+        incrementErrors();
+    }
+    else if (str.find("WARNING") != string::npos)
+    {
+        incrementWarnings();
     }
 }
 
-void FileHandler::Write(const char* string,...)
+void FileHandler::Write(const char* str_msg,...)
 {
-    char msg[CLENGTH];
-    va_list ap;
-    va_start (ap, string);
-    vsprintf (msg,string ,ap);
-    va_end (ap);
-    pfp<<msg<<endl;
-    pfp.flush();
+     char msg[CLENGTH]="";
+     va_list ap;
+     va_start (ap, str_msg);
+     vsprintf (msg,str_msg ,ap);
+     va_end (ap);
+     _pfp<<msg<<endl;
+     _pfp.flush();
+
+     string str(msg);
+     if (str.find("ERROR") != string::npos)
+     {
+         incrementErrors();
+     }
+     else if (str.find("WARNING") != string::npos)
+     {
+         incrementWarnings();
+     }
 }
 
-TraVisToHandler::TraVisToHandler(string host, int port)
+#ifdef _SIMULATOR
+
+SocketHandler::SocketHandler(const string& host, int port)
 {
-    client = new TraVisToClient(host, port);
-    brokentags.push_back("<trajectoriesDataset>");
-    brokentags.push_back("</trajectoriesDataset>");
-    brokentags.push_back("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+     client = new TraVisToClient(host, port);
+     brokentags.push_back("<trajectories>");
+     brokentags.push_back("</trajectories>");
+     brokentags.push_back("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
 }
 
-TraVisToHandler::~TraVisToHandler()
+SocketHandler::~SocketHandler()
 {
-    delete client;
+     delete client;
 }
 
-void TraVisToHandler::Write(string str)
+void SocketHandler::Write(const string& stringRef)
 {
 
-    vector<string>::iterator str_it;
-
-    //There are a few broken tags which need to be checked for and removed.
-    for (str_it = brokentags.begin(); str_it != brokentags.end(); ++str_it) {
-        int tagstart = str.find(*str_it);
-        if (tagstart != (int) string::npos) {
-            str.erase(str.begin() + tagstart, str.begin() + tagstart + (*str_it).size());
-        }
-    }
-    client->sendData(str.c_str());
+     vector<string>::iterator str_it;
+     string str=stringRef;
+
+     //There are a few broken tags which need to be checked for and removed.
+     for (str_it = brokentags.begin(); str_it != brokentags.end(); ++str_it) {
+          int tagstart = str.find(*str_it);
+          if (tagstart != (int) string::npos) {
+               str.erase(str.begin() + tagstart, str.begin() + tagstart + (*str_it).size());
+          }
+     }
+     client->sendData(str.c_str());
 }
 
-
-
-
-
+#endif
diff --git a/src/IO/OutputHandler.h b/src/IO/OutputHandler.h
index 1a2841bbf5ecf0bc9c91accda0df3898ab051c88..95f7c5865455978e888254ec43c217acb35d4bde 100644
--- a/src/IO/OutputHandler.h
+++ b/src/IO/OutputHandler.h
@@ -1,13 +1,14 @@
 /**
- * File:   OutputHandler.h
+ * \file        OutputHandler.h
+ * \date        Nov 20, 2010
+ * \version     v0.6
+ * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
- * Created on 20. November 2010, 15:20
- *
- * @section LICENSE
+ * \section License
  * This file is part of JuPedSim.
  *
  * JuPedSim is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * it under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
  * any later version.
  *
@@ -16,14 +17,14 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Lesser General Public License
  * along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
  *
- * @section DESCRIPTION
- *
+ * \section Description
  *
  *
- */
+ **/
+ 
 
 #ifndef OUTPUT_HANDLER_H_
 #define OUTPUT_HANDLER_H_
@@ -32,48 +33,61 @@
 #include <fstream>
 #include <vector>
 
+#include "../general/Macros.h"
 
+#ifdef _SIMULATOR
 #include "../IO/TraVisToClient.h"
-#include "../general/Macros.h"
+#endif
+
 
 class OutputHandler {
+protected:
+     int _nWarnings;
+     int _nErrors;
 public:
-    virtual void Write(std::string str);
-    virtual void Write(const char *string, ...);
-    virtual ~OutputHandler() {};
+     OutputHandler() { _nWarnings = 0; _nErrors = 0; };
+     virtual ~OutputHandler() {};
+
+     int GetWarnings();
+     void incrementWarnings();
+     int GetErrors();
+     void incrementErrors();
+     void ProgressBar(double TotalPeds, double NowPeds);
+
+     virtual void Write(const std::string& str);
+     virtual void Write(const char *string, ...);
 };
 
 class STDIOHandler : public OutputHandler {
 public:
-    void Write(std::string str);
+     void Write(const std::string& str);
 };
 
 class FileHandler : public OutputHandler {
 private:
-    std::ofstream pfp;
-
+     std::ofstream _pfp;
 public:
-    FileHandler(const char *fn);
-    virtual ~FileHandler();
-    void Write(std::string str);
-    void Write(const char *string,...);
+     FileHandler(const char *fn);
+     virtual ~FileHandler();
+     void Write(const std::string& str);
+     void Write(const char *string,...);
 };
 
-class TraVisToHandler : public OutputHandler {
+#ifdef _SIMULATOR
+
+class SocketHandler : public OutputHandler {
 private:
-    TraVisToClient* client;
+     TraVisToClient* client;
 
 public:
-    TraVisToHandler(std::string host, int port);
-    virtual ~TraVisToHandler();
-    void Write(std::string str);
+     SocketHandler(const std::string& host, int port);
+     virtual ~SocketHandler();
+     void Write(const std::string& str);
 
-    //Some tags are broken
-    std::vector<std::string> brokentags;
+     //Some tags are broken
+     std::vector<std::string> brokentags;
 };
 
-
-
+#endif
 
 #endif /*OUTPUT_HANDLER_H_*/
-
diff --git a/src/IO/TraVisToClient.cpp b/src/IO/TraVisToClient.cpp
old mode 100755
new mode 100644
index ffa8ffb8b9844ff59a47422dc751279143644861..5622262ed72bf4117479febb58b03945de2ea1cc
--- a/src/IO/TraVisToClient.cpp
+++ b/src/IO/TraVisToClient.cpp
@@ -1,28 +1,29 @@
 /**
- * TraVisToClient.cpp
- * Copyright (C) <2009-2010>  <Ulrich Kemloh>
+ * \file        travistoclient.cpp
+ * \date        jul 4, 2014
+ * \version     v0.6
+ * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. all rights reserved.
  *
- * @section LICENSE
- * This file is part of JuPedSim.
+ * \section license
+ * this file is part of jupedsim.
  *
  * JuPedSim is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
+ * it under the terms of the gnu lesser general public license as published by
+ * the free software foundation, either version 3 of the license, or
  * any later version.
  *
  * JuPedSim is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
- *
- * @section DESCRIPTION
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. see the
+ * gnu general public license for more details.
  *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with JuPedSim. if not, see <http://www.gnu.org/licenses/>.
  *
+ * \section Description
+
  *
- */
+ **/
 
 
 /********* include files ******************************************************/
@@ -31,115 +32,113 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
-
-
 #include "TraVisToClient.h"
+#include "../general/Macros.h"
+
 
+//using namespace std;
+using std::string;
 
-using namespace std;
 
 TraVisToClient::TraVisToClient(string hostname, unsigned short port)
 {
-    _hostname=hostname;
-    _port = port;
-    _isConnected = false;
-    createConnection();
-
-
+     _hostname=hostname;
+     _port = port;
+     _isConnected = false;
+     createConnection();
 }
 
 TraVisToClient::~TraVisToClient()
 {
-    if (_isConnected) close();
+     if (_isConnected) close();
 }
 
-
 /// send datablock to the server
 
 void TraVisToClient::sendData(const char* data)
 {
 
-    // first create a new connection, in the case the last one was lost/close
-
-    if (!_isConnected) {
-        createConnection();
-        //FIXME: queue messsage in a vector
-        // msgQueue.push_back(data);
-        return;
-
-    }
-    char msgSizeStr[10];
-    int msgSize = (int)strlen(data);
-    sprintf(msgSizeStr, "%d\n", msgSize);
-
-    /* check if parameters are valid */
-    if (NULL == data) {
-        fprintf(stderr, "invalid message buffer!");
-        fprintf(stderr, "leaving sendMessage()");
-        _isConnected = false;
-        return;
-    }
-
-
-    //  do until queue empty for()
-
-
-    /*send the length of the message*/
-    int msgsize = strlen(msgSizeStr);
-    if (msgsize != send(_tcpSocket, (const char *) msgSizeStr, strlen(msgSizeStr), 0)) {
-        fprintf(stderr, "sending message Size failed");
-        fprintf(stderr, "leaving sendMessage()");
-        _isConnected = false;
-        return;
-    }
-
-    /* now send the message */
-    if (msgSize != send(_tcpSocket, (const char *) data, msgSize, 0)) {
-        fprintf(stderr, "sending message failed");
-        fprintf(stderr, "leaving sendMessage()");
-        _isConnected = false;
-        return;
-    }
-
-    // end do
+     // first create a new connection, in the case the last one was lost/close
+
+     if (!_isConnected) {
+          createConnection();
+          //FIXME: queue messsage in a vector
+          // msgQueue.push_back(data);
+          return;
+
+     }
+     char msgSizeStr[10];
+     int msgSize = (int)strlen(data);
+     sprintf(msgSizeStr, "%d\n", msgSize);
+
+     /* check if parameters are valid */
+     if (NULL == data) {
+          fprintf(stderr, "invalid message buffer!");
+          fprintf(stderr, "leaving sendMessage()");
+          _isConnected = false;
+          return;
+     }
+
+
+     //  do until queue empty for()
+
+
+     /*send the length of the message*/
+     int msgsize = strlen(msgSizeStr);
+     if (msgsize != send(_tcpSocket, (const char *) msgSizeStr, strlen(msgSizeStr), 0)) {
+          fprintf(stderr, "sending message Size failed");
+          fprintf(stderr, "leaving sendMessage()");
+          _isConnected = false;
+          return;
+     }
+
+     /* now send the message */
+     if (msgSize != send(_tcpSocket, (const char *) data, msgSize, 0)) {
+          fprintf(stderr, "sending message failed");
+          fprintf(stderr, "leaving sendMessage()");
+          _isConnected = false;
+          return;
+     }
+
+     // end do
 }
 
 /// close the client (end the connection)
 
 void TraVisToClient::close()
 {
-    if (_isConnected) {
-        /* all things are done, so shutdown the connection */
-        if (!shutdownAndCloseSocket(_tcpSocket)) {
-            fprintf(stderr, "shutdown and close socket failed!");
-            stopSocketSession();
-            fprintf(stderr, "leaving main() with error");
-            return;
-        }
-
-        /* stop the socket session */
-        stopSocketSession();
-    }
+     if (_isConnected) {
+          /* all things are done, so shutdown the connection */
+          if (!shutdownAndCloseSocket(_tcpSocket)) {
+               fprintf(stderr, "shutdown and close socket failed!");
+               stopSocketSession();
+               fprintf(stderr, "leaving main() with error");
+               return;
+          }
+
+          /* stop the socket session */
+          stopSocketSession();
+     }
 
 }
 
 void TraVisToClient::createConnection()
 {
 
-    /* start the socket session */
-    if (!startSocketSession()) {
-        fprintf(stderr, "startSocketSession() failed!");
-        fprintf(stderr, "socket creation failed for host [%s] on port [%d]!",_hostname.c_str(),_port);
-        exit(EXIT_FAILURE);
-    }
-
-    /* create a new socket and connect the socket to the given service */
-    if (INVALID_SOCKET == (_tcpSocket = createClientSocket(_hostname.c_str(), _port))) {
-        fprintf(stderr, "\nsocket creation failed for host [%s] on port [%d]!\n",_hostname.c_str(),_port);
-        stopSocketSession();
-        exit(EXIT_FAILURE);
-    }
-    _isConnected = true;
+     /* start the socket session */
+     if (!startSocketSession()) {
+          fprintf(stderr, "startSocketSession() failed!");
+          fprintf(stderr, "socket creation failed for host [%s] on port [%d]!",_hostname.c_str(),_port);
+          exit(EXIT_FAILURE);
+     }
+
+     /* create a new socket and connect the socket to the given service */
+     if (INVALID_SOCKET == (_tcpSocket = createClientSocket(_hostname.c_str(), _port))) {
+          fprintf(stderr, "\nsocket creation failed for host [%s] on port [%d]!\n",_hostname.c_str(),_port);
+          stopSocketSession();
+          exit(EXIT_FAILURE);
+     }
+     _isConnected = true;
 }
 
 /********* function definitions **************************************/
@@ -158,31 +157,31 @@ void TraVisToClient::createConnection()
 unsigned long
 TraVisToClient::lookupHostAddress(const char *hostName)
 {
-    unsigned long addr; /* inet address of hostname */
-    struct hostent *host; /* host structure for DNS request */
+     unsigned long addr; /* inet address of hostname */
+     struct hostent *host; /* host structure for DNS request */
 
-    dtrace("entering lookupHostAddress()");
+     dtrace("entering lookupHostAddress()");
 
-    if (NULL == hostName) {
-        derror("invalid parameter");
-        dtrace("leaving lookupHostAddress()");
-        return (INADDR_NONE);
-    }
+     if (NULL == hostName) {
+          derror("invalid parameter");
+          dtrace("leaving lookupHostAddress()");
+          return (INADDR_NONE);
+     }
 
-    dtrace("looking for host %s", hostName);
+     dtrace("looking for host %s", hostName);
 
-    addr = inet_addr(hostName);
+     addr = inet_addr(hostName);
 
-    if (INADDR_NONE == addr) {
-        /* hostName isn't a dotted IP, so resolve it through DNS */
-        host = gethostbyname(hostName);
-        if (NULL != host) {
-            addr = *((unsigned long *) host->h_addr);
-        }
-    }
+     if (INADDR_NONE == addr) {
+          /* hostName isn't a dotted IP, so resolve it through DNS */
+          host = gethostbyname(hostName);
+          if (NULL != host) {
+               addr = *((unsigned long *) host->h_addr);
+          }
+     }
 
-    dtrace("leaving lookupHostAddress()");
-    return (addr);
+     dtrace("leaving lookupHostAddress()");
+     return (addr);
 }
 /******** end of function lookupHostAddress **************************/
 
@@ -200,45 +199,45 @@ TraVisToClient::lookupHostAddress(const char *hostName)
 socket_t
 TraVisToClient::createClientSocket(const char *serverName, unsigned short portNumber)
 {
-    unsigned long ipAddress; /* internet address */
-    struct sockaddr_in srvAddr; /* server's internet socket address */
-    socket_t sock; /* file descriptor for client socket */
-
-    dtrace("entering createClientSocket()");
-
-    /* get the IP address of the server host */
-    if (INADDR_NONE == (ipAddress = lookupHostAddress(serverName))) {
-        derror("lookupHostAddress() failed");
-        dtrace("leaving createClientSocket() with INVALID_SOCKET");
-        return (INVALID_SOCKET);
-    }
-
-    dtrace("trying to connect %s on port %hu", serverName, portNumber);
-
-    /* create the client socket */
-    if (INVALID_SOCKET == (sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP))) {
-        derror("socket creation failed");
-        dtrace("leaving createClientSocket() with INVALID_SOCKET");
-        return (INVALID_SOCKET);
-    }
-
-    /* fill the server address structure */
-    memset(&srvAddr, 0, sizeof (srvAddr));
-    srvAddr.sin_family = AF_INET;
-    srvAddr.sin_port = htons(portNumber);
-    srvAddr.sin_addr.s_addr = ipAddress;
-
-    /* try to connect to the server socket */
-    if (SOCKET_ERROR == connect(sock, (struct sockaddr *) & srvAddr, sizeof (srvAddr))) {
-        derror("connect() failed");
-        //FIXME
-        //closesocket(tcpSocket);
-        dtrace("leaving createClientSocket() with INVALID_SOCKET");
-        return (INVALID_SOCKET);
-    }
-
-    dtrace("leaving createClientSocket()");
-    return (sock);
+     unsigned long ipAddress; /* internet address */
+     struct sockaddr_in srvAddr; /* server's internet socket address */
+     socket_t sock; /* file descriptor for client socket */
+
+     dtrace("entering createClientSocket()");
+
+     /* get the IP address of the server host */
+     if (INADDR_NONE == (ipAddress = lookupHostAddress(serverName))) {
+          derror("lookupHostAddress() failed");
+          dtrace("leaving createClientSocket() with INVALID_SOCKET");
+          return (INVALID_SOCKET);
+     }
+
+     dtrace("trying to connect %s on port %hu", serverName, portNumber);
+
+     /* create the client socket */
+     if (INVALID_SOCKET == (sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP))) {
+          derror("socket creation failed");
+          dtrace("leaving createClientSocket() with INVALID_SOCKET");
+          return (INVALID_SOCKET);
+     }
+
+     /* fill the server address structure */
+     memset(&srvAddr, 0, sizeof (srvAddr));
+     srvAddr.sin_family = AF_INET;
+     srvAddr.sin_port = htons(portNumber);
+     srvAddr.sin_addr.s_addr = ipAddress;
+
+     /* try to connect to the server socket */
+     if (SOCKET_ERROR == connect(sock, (struct sockaddr *) & srvAddr, sizeof (srvAddr))) {
+          derror("connect() failed");
+          //FIXME
+          //closesocket(tcpSocket);
+          dtrace("leaving createClientSocket() with INVALID_SOCKET");
+          return (INVALID_SOCKET);
+     }
+
+     dtrace("leaving createClientSocket()");
+     return (sock);
 }
 /******** end of function createClientSocket *************************/
 
@@ -253,45 +252,45 @@ TraVisToClient::createClientSocket(const char *serverName, unsigned short portNu
 socket_t
 TraVisToClient::createServerSocket(unsigned short portNumber)
 {
-    struct sockaddr_in srvAddr; /* server's internet socket address */
-    socket_t sock; /* file descriptor for server socket */
-
-    dtrace("entering createServerSocket()");
-
-    /* create the server socket */
-    if (INVALID_SOCKET == (sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP))) {
-        derror("socket creation failed");
-        dtrace("leaving createServerSocket() with INVALID_SOCKET");
-        return (INVALID_SOCKET);
-    }
-
-    /* fill the server address structure */
-    /* first of all, zero srvAddr, so that we have a defined status */
-    memset(&srvAddr, 0, sizeof (srvAddr));
-    srvAddr.sin_family = AF_INET;
-    srvAddr.sin_port = htons(portNumber);
-    srvAddr.sin_addr.s_addr = htonl(INADDR_ANY);
-
-    /* try to bind socket to the specified server port */
-    if (SOCKET_ERROR == ::bind(sock, (struct sockaddr *) & srvAddr, sizeof (srvAddr))) {
-        derror("bind() failed!");
-        //FIXME:
-        //closesocket(tcpSocket);
-        dtrace("leaving createServerSocket() with INVALID_SOCKET");
-        return (INVALID_SOCKET);
-    }
-
-    if (SOCKET_ERROR == listen(sock, QUEUE_LENGTH)) {
-        derror("listen() failed!");
-        shutdownAndCloseSocket(sock);
-        dtrace("leaving createServerSocket() with INVALID_SOCKET");
-        return (INVALID_SOCKET);
-    }
-
-    dtrace("server started at port %hu", portNumber);
-
-    dtrace("leaving createServerSocket()");
-    return (sock);
+     struct sockaddr_in srvAddr; /* server's internet socket address */
+     socket_t sock; /* file descriptor for server socket */
+
+     dtrace("entering createServerSocket()");
+
+     /* create the server socket */
+     if (INVALID_SOCKET == (sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP))) {
+          derror("socket creation failed");
+          dtrace("leaving createServerSocket() with INVALID_SOCKET");
+          return (INVALID_SOCKET);
+     }
+
+     /* fill the server address structure */
+     /* first of all, zero srvAddr, so that we have a defined status */
+     memset(&srvAddr, 0, sizeof (srvAddr));
+     srvAddr.sin_family = AF_INET;
+     srvAddr.sin_port = htons(portNumber);
+     srvAddr.sin_addr.s_addr = htonl(INADDR_ANY);
+
+     /* try to bind socket to the specified server port */
+     if (SOCKET_ERROR == bind(sock, (struct sockaddr *) & srvAddr, sizeof (srvAddr))) {
+          derror("bind() failed!");
+          //FIXME:
+          //closesocket(tcpSocket);
+          dtrace("leaving createServerSocket() with INVALID_SOCKET");
+          return (INVALID_SOCKET);
+     }
+
+     if (SOCKET_ERROR == listen(sock, QUEUE_LENGTH)) {
+          derror("listen() failed!");
+          shutdownAndCloseSocket(sock);
+          dtrace("leaving createServerSocket() with INVALID_SOCKET");
+          return (INVALID_SOCKET);
+     }
+
+     dtrace("server started at port %hu", portNumber);
+
+     dtrace("leaving createServerSocket()");
+     return (sock);
 }
 /******** end of function createServerSocket *************************/
 
@@ -309,32 +308,32 @@ TraVisToClient::createServerSocket(unsigned short portNumber)
 bool
 TraVisToClient::sendMessage(socket_t sock, const void *msg, int msgSize)
 {
-    dtrace("entering sendMessage()");
-
-    /* check if parameters are valid */
-    if (NULL == msg) {
-        derror("invalid message buffer!");
-        dtrace("leaving sendMessage()");
-        return (false);
-    }
-
-    if (0 >= msgSize) {
-        derror("invalid message size %d", msgSize);
-        dtrace("leaving sendMessage()");
-        return (false);
-    }
-
-    dtrace("sending message of size %d", msgSize);
-
-    /* now send the message */
-    if (msgSize != send(sock, (const char *) msg, msgSize, 0)) {
-        derror("sending message failed");
-        dtrace("leaving sendMessage()");
-        return (false);
-    }
-
-    dtrace("leaving sendMessage()");
-    return (true);
+     dtrace("entering sendMessage()");
+
+     /* check if parameters are valid */
+     if (NULL == msg) {
+          derror("invalid message buffer!");
+          dtrace("leaving sendMessage()");
+          return (false);
+     }
+
+     if (0 >= msgSize) {
+          derror("invalid message size %d", msgSize);
+          dtrace("leaving sendMessage()");
+          return (false);
+     }
+
+     dtrace("sending message of size %d", msgSize);
+
+     /* now send the message */
+     if (msgSize != send(sock, (const char *) msg, msgSize, 0)) {
+          derror("sending message failed");
+          dtrace("leaving sendMessage()");
+          return (false);
+     }
+
+     dtrace("leaving sendMessage()");
+     return (true);
 }
 /******** end of function sendMessage ********************************/
 
@@ -354,56 +353,56 @@ TraVisToClient::sendMessage(socket_t sock, const void *msg, int msgSize)
 bool
 TraVisToClient::receiveMessage(socket_t sock, void *msg, int msgSize)
 {
-    char *msgPart; /* pointer to the memory for receiving the message */
-    int toReceive; /* number of bytes to receive */
-    int received; /* number of bytes totally received */
-    int nBytes; /* number of bytes currently received */
-
-    dtrace("entering receiveMessage()");
-
-    /* check if parameters are valid */
-    if (NULL == msg) {
-        derror("invalid message buffer!");
-        dtrace("leaving receiveMessage()");
-        return (false);
-    }
-
-    if (0 >= msgSize) {
-        derror("invalid message size!");
-        dtrace("leaving receiveMessage()");
-        return (false);
-    }
-
-    msgPart = (char *) msg;
-    received = 0;
-
-    dtrace("trying to receive a message of size %d", msgSize);
-
-    /* start receiving bytes from server until complete message is received */
-    do {
-        toReceive = msgSize - received;
-        nBytes = recv(sock, msgPart, toReceive, 0);
-        switch (nBytes) {
-        case SOCKET_ERROR: /* error occurred */
-            derror("error during message receipt");
-            dtrace("leaving receiveMessage()");
-            return (false);
-        case 0: /* connection has been closed */
-            derror("remote host has closed the connection");
-            dtrace("leaving receiveMessage()");
-            return (false);
-        default: /* some bytes have been received */
-            dtrace("received %d bytes of message", nBytes);
-            received += nBytes;
-            msgPart += nBytes;
-            break;
-        }
-    } while (received != msgSize);
-
-    dtrace("received message of size %d", received);
-
-    dtrace("leaving receiveMessage()");
-    return (true);
+     char *msgPart; /* pointer to the memory for receiving the message */
+     int toReceive; /* number of bytes to receive */
+     int received; /* number of bytes totally received */
+     int nBytes; /* number of bytes currently received */
+
+     dtrace("entering receiveMessage()");
+
+     /* check if parameters are valid */
+     if (NULL == msg) {
+          derror("invalid message buffer!");
+          dtrace("leaving receiveMessage()");
+          return (false);
+     }
+
+     if (0 >= msgSize) {
+          derror("invalid message size!");
+          dtrace("leaving receiveMessage()");
+          return (false);
+     }
+
+     msgPart = (char *) msg;
+     received = 0;
+
+     dtrace("trying to receive a message of size %d", msgSize);
+
+     /* start receiving bytes from server until complete message is received */
+     do {
+          toReceive = msgSize - received;
+          nBytes = recv(sock, msgPart, toReceive, 0);
+          switch (nBytes) {
+          case SOCKET_ERROR: /* error occurred */
+               derror("error during message receipt");
+               dtrace("leaving receiveMessage()");
+               return (false);
+          case 0: /* connection has been closed */
+               derror("remote host has closed the connection");
+               dtrace("leaving receiveMessage()");
+               return (false);
+          default: /* some bytes have been received */
+               dtrace("received %d bytes of message", nBytes);
+               received += nBytes;
+               msgPart += nBytes;
+               break;
+          }
+     } while (received != msgSize);
+
+     dtrace("received message of size %d", received);
+
+     dtrace("leaving receiveMessage()");
+     return (true);
 }
 /******** end of function receiveMessage *****************************/
 
@@ -418,23 +417,23 @@ TraVisToClient::receiveMessage(socket_t sock, void *msg, int msgSize)
 bool
 TraVisToClient::shutdownAndCloseSocket(socket_t sock)
 {
-    bool status = true;
+     bool status = true;
 
-    dtrace("entering shutdownAndCloseSocket()");
+     dtrace("entering shutdownAndCloseSocket()");
 
-    if (SOCKET_ERROR == shutdown(sock, SHUT_RDWR)) {
-        derror("shutdown() failed");
-        status = false;
-    }
+     if (SOCKET_ERROR == shutdown(sock, SHUT_RDWR)) {
+          derror("shutdown() failed");
+          status = false;
+     }
 
-    //FIXME:
-    //if (SOCKET_ERROR == closesocket(tcpSocket)) {
-    //	derror("closesocket() failed");
-    //	status = false;
-    //}
+     //FIXME:
+     //if (SOCKET_ERROR == closesocket(tcpSocket)) {
+     //  derror("closesocket() failed");
+     //  status = false;
+     //}
 
-    dtrace("leaving shutdownAndCloseSocket()");
-    return (status);
+     dtrace("leaving shutdownAndCloseSocket()");
+     return (status);
 }
 
 /******** end of function shutdownAndCloseSocket *********************/
@@ -456,37 +455,37 @@ TraVisToClient::_printErrorMessage(void)
 bool
 TraVisToClient::_startWin32SocketSession(void)
 {
-    WORD requestedVersion;
-    WSADATA wsaData;
+     WORD requestedVersion;
+     WSADATA wsaData;
 
-    dtrace("entering _startWin32SocketSession()");
+     dtrace("entering _startWin32SocketSession()");
 
-    requestedVersion = MAKEWORD(WS_MAJOR_VERSION, WS_MINOR_VERSION);
+     requestedVersion = MAKEWORD(WS_MAJOR_VERSION, WS_MINOR_VERSION);
 
-    if (0 != WSAStartup(requestedVersion, &wsaData)) {
-        derror("WSAStartup() failed");
-        dtrace("leaving _startWin32SocketSession() with error");
-        return (false);
-    }
+     if (0 != WSAStartup(requestedVersion, &wsaData)) {
+          derror("WSAStartup() failed");
+          dtrace("leaving _startWin32SocketSession() with error");
+          return (false);
+     }
 
-    /* Confirm that the Windows Socket DLL supports 1.1. */
-    /* Note that if the DLL supports versions greater    */
-    /* than 1.1 in addition to 1.1, it will still return */
-    /* 1.1 in wVersion since that is the version we      */
-    /* requested.                                        */
+     /* Confirm that the Windows Socket DLL supports 1.1. */
+     /* Note that if the DLL supports versions greater    */
+     /* than 1.1 in addition to 1.1, it will still return */
+     /* 1.1 in wVersion since that is the version we      */
+     /* requested.                                        */
 
-    if (WS_MINOR_VERSION != LOBYTE(wsaData.wVersion)
-            || WS_MAJOR_VERSION != HIBYTE(wsaData.wVersion)) {
-        derror("Windows Socket DLL does not support the requested version");
-        _stopWin32SocketSession();
-        dtrace("leaving _startWin32SocketSession() with error");
-        return (false);
-    }
+     if (WS_MINOR_VERSION != LOBYTE(wsaData.wVersion)
+               || WS_MAJOR_VERSION != HIBYTE(wsaData.wVersion)) {
+          derror("Windows Socket DLL does not support the requested version");
+          _stopWin32SocketSession();
+          dtrace("leaving _startWin32SocketSession() with error");
+          return (false);
+     }
 
-    WSASetLastError(0); /* reset the error code */
+     WSASetLastError(0); /* reset the error code */
 
-    dtrace("leaving _startWin32SocketSession()");
-    return (true);
+     dtrace("leaving _startWin32SocketSession()");
+     return (true);
 }
 /******** end of function _startWin32SocketSession *******************/
 
@@ -497,14 +496,14 @@ TraVisToClient::_startWin32SocketSession(void)
 void
 TraVisToClient::_stopWin32SocketSession(void)
 {
-    dtrace("entering _stopWin32SocketSession()");
+     dtrace("entering _stopWin32SocketSession()");
 
-    if (SOCKET_ERROR == WSACleanup()) {
-        derror("WSACleanup() failed");
-    }
+     if (SOCKET_ERROR == WSACleanup()) {
+          derror("WSACleanup() failed");
+     }
 
-    dtrace("leaving _stopWin32SocketSession()");
-    return;
+     dtrace("leaving _stopWin32SocketSession()");
+     return;
 }
 /******** end of function _stopWin32SocketSession ********************/
 
diff --git a/src/IO/TraVisToClient.h b/src/IO/TraVisToClient.h
index 12d375cc1722ad8f7fcc63dec41a4ce129096854..cf93ad0f6314f664e6f554ecdcb038d99fecbdf7 100644
--- a/src/IO/TraVisToClient.h
+++ b/src/IO/TraVisToClient.h
@@ -1,12 +1,14 @@
 /**
+ * \file        TraVisToClient.h
+ * \date        Jul 4, 2014
+ * \version     v0.6
+ * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
- * Copyright (C) <2009-2010>  <Ulrich Kemloh>
- *
- * @section LICENSE
+ * \section License
  * This file is part of JuPedSim.
  *
  * JuPedSim is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * it under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
  * any later version.
  *
@@ -15,14 +17,14 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Lesser General Public License
  * along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
  *
- * @section DESCRIPTION
- *
+ * \section Description
  *
  *
- */
+ **/
+
 
 #ifndef TRAVISTOCLIENT_H_
 #define TRAVISTOCLIENT_H_
@@ -33,29 +35,58 @@
 #include <string.h>
 #include <stdbool.h>
 
-#ifdef _WIN32
+// #ifdef _WIN32
 
-#endif
+// #endif
 
 #define QUEUE_LENGTH       5        ///< max queue length of pending connections
 
-/******** macro definitions ******************************************/
+// inline
+// void
+// _printDebugLine(const char *fileName, int lineNumber)
+// {
+//   fprintf(stderr, "%-15s|%03d| ", fileName, lineNumber);
+// }
 
-#ifdef TRACE_LOGGING
 
-#define dtrace(...)   _printDebugLine(__FILE__, __LINE__, false, __VA_ARGS__)
-#define derror(...)   _printDebugLine(__FILE__, __LINE__, true, __VA_ARGS__)
+// #ifdef TRACE_LOGGING
 
-#else
+/*
+ #define dtrace(...)                         \
+     (_printDebugLine(__FILE__, __LINE__),   \
+     fprintf(stderr, __VA_ARGS__),           \
+     (void) fprintf(stderr, "\n"))
+
+ #define derror(...)                         \
+     (_printDebugLine(__FILE__, __LINE__),   \
+     fprintf(stderr, "ERROR: "),             \
+     fprintf(stderr, __VA_ARGS__),           \
+     _printErrorMessage())
+*/
 
-#define dtrace(...)   ((void) 0)
-#define derror(...)   (fprintf(stderr, __VA_ARGS__), _printErrorMessage())
 
-#endif /* TRACE_LOGGING */
+// // #define dtrace(...)   _printDebugLine(__FILE__, __LINE__, false, __VA_ARGS__)
+// // #define derror(...)   _printDebugLine(__FILE__, __LINE__, true, __VA_ARGS__)
+
+// #else
+
+// #define dtrace(...)   ((void) 0)
+// #define derror(...)   (fprintf(stderr, __VA_ARGS__), _printErrorMessage())
+
+// #endif /* TRACE_LOGGING */
 
 
 #ifdef _WIN32
-#include <winsock.h>
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+
+#include <windows.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <iphlpapi.h>
+
+#pragma comment(lib, "Ws2_32.lib")
 #define WS_MAJOR_VERSION   1        ///< major version of Winsock API
 #define WS_MINOR_VERSION   1        ///< minor version of Winsock API
 #define SHUT_RDWR          2  ///< @c SHUT_RDWR is POSIX standard
@@ -93,44 +124,44 @@ typedef int socket_t;
 class TraVisToClient {
 public:
 
-    /// create a client with specific parameters
-    TraVisToClient(std::string hostname = HOST, unsigned short port = PORT);
+     /// create a client with specific parameters
+     TraVisToClient(std::string hostname = HOST, unsigned short port = PORT);
 
-    /// Destructor
-    virtual ~TraVisToClient();
+     /// Destructor
+     virtual ~TraVisToClient();
 
-    /// send datablock to the server
-    /// this functions is still blocking unfortunately, so it may
-    /// influence the execution time of your program
-    void sendData(const char* data);
+     /// send datablock to the server
+     /// this functions is still blocking unfortunately, so it may
+     /// influence the execution time of your program
+     void sendData(const char* data);
 
-    /// close the client (end the connection)
-    void close();
+     /// close the client (end the connection)
+     void close();
 
-    /// send a datagram using the unreliable
-    /// udp protokoll
-    void sendDatagram(char *datagram);
+     /// send a datagram using the unreliable
+     /// udp protokoll
+     void sendDatagram(char *datagram);
 
 private:
-    void createConnection();
+     void createConnection();
 
-    unsigned long lookupHostAddress(const char *hostName);
+     unsigned long lookupHostAddress(const char *hostName);
 
-    socket_t createClientSocket(const char *serverName, unsigned short portNumber);
+     socket_t createClientSocket(const char *serverName, unsigned short portNumber);
 
-    socket_t createServerSocket(unsigned short portNumber);
+     socket_t createServerSocket(unsigned short portNumber);
 
-    bool shutdownAndCloseSocket(socket_t sock);
+     bool shutdownAndCloseSocket(socket_t sock);
 
-    bool sendMessage(socket_t sock, const void *msg, int msgSize);
+     bool sendMessage(socket_t sock, const void *msg, int msgSize);
 
-    bool receiveMessage(socket_t sock, void *msg, int msgSize);
+     bool receiveMessage(socket_t sock, void *msg, int msgSize);
 
-    void _printErrorMessage(void);
+     void _printErrorMessage(void);
 
 #ifdef _WIN32
-    bool _startWin32SocketSession(void);
-    void _stopWin32SocketSession(void);
+     bool _startWin32SocketSession(void);
+     void _stopWin32SocketSession(void);
 #else
 #define closesocket          close
 #endif
@@ -138,11 +169,11 @@ private:
 
 
 private:
-    bool _isConnected;
-    socket_t _tcpSocket;
-    std::string _hostname;
-    unsigned short _port;
-    std::vector<const char *> _msgQueue;
+     bool _isConnected;
+     socket_t _tcpSocket;
+     std::string _hostname;
+     unsigned short _port;
+     std::vector<const char *> _msgQueue;
 
 };
 
diff --git a/src/InteractorStyle.cpp b/src/InteractorStyle.cpp
index aacc6efec04bb102cc1bdda02742f655b5be8037..822824dbe31adeef1a1b31b9b484dfd876bc4a41 100644
--- a/src/InteractorStyle.cpp
+++ b/src/InteractorStyle.cpp
@@ -333,7 +333,7 @@ void InteractorStyle::OnLeftButtonUp()
     world[0]/=100;
     world[1]/=100;
     world[2]/=100;
-
+    cout.precision(2);
     std::cout<<"mouse position: " <<endl;
     std::cout<<"\t screen: " <<pos_x<<" "<<pos_y<<endl;
     std::cout<<"\t world : " <<world[0] << " " << world[1] << " " << world[2] << std::endl;
diff --git a/src/TimerCallback.cpp b/src/TimerCallback.cpp
index 776c88af821f791d5a1fc3bb3f8026ed9467623c..e5e71f43bdaef9a34fa808b3864892f8f39bab9d 100644
--- a/src/TimerCallback.cpp
+++ b/src/TimerCallback.cpp
@@ -199,7 +199,7 @@ void TimerCallback::Execute(vtkObject *caller, unsigned long eventId,
                 runningTime->SetInput(runningTimeText);
                 runningTime->Modified();
 
-                if((lastWinX!=winSize[0]) || (lastWinY!=winSize[1]) || (frameNumber<10)) {
+                if((lastWinX!=winSize[0]) || (lastWinY!=winSize[1]) /*|| (frameNumber<10)*/) {
                     static std::string winBaseName(renderWindow->GetWindowName());
                     std::string winName=winBaseName;
                     std::string s;
diff --git a/src/general/Macros.h b/src/general/Macros.h
index c49a8bfd89e49aa867608c9638138659810b3acc..3558ee36d09b3a6573e5b305cb7243485be09bd5 100644
--- a/src/general/Macros.h
+++ b/src/general/Macros.h
@@ -1,13 +1,14 @@
 /**
- * File:   Macros.h
+ * \file        Macros.h
+ * \date        Jun 16, 2010
+ * \version     v0.6
+ * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
- * Created on 16. Juni 2010, 16:59
- *
- * @section LICENSE
+ * \section License
  * This file is part of JuPedSim.
  *
  * JuPedSim is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * it under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
  * any later version.
  *
@@ -16,118 +17,255 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Lesser General Public License
  * along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
  *
- * @section DESCRIPTION
+ * \section Description
+ * useful constants
  *
  *
- */
+ **/
+ 
 
 #ifndef _MACROS_H
 #define _MACROS_H
 
 #include <cstdlib>
 #include <vector>
+#include <map>
 #include <string.h>
+#include <algorithm>
+#include <sstream>
+
 
+#define _USE_MATH_DEFINES
+#include <math.h>
+#define M_PI   3.14159265358979323846
+
+// should be true only when using this file in the simulation core
 //#define _SIMULATOR 1
 
+
+#define JPS_VERSION "0.5"
+#define JPS_VERSION_MINOR 5
+#define JPS_VERSION_MAJOR 0
+
+// disable openmp in debug mode
 #ifdef _NDEBUG
 //#undef _OPENMP
 #endif
 
 // precision error
 #define J_EPS 0.001
+#define J_EPS_EVENT 0.00001 //zum pruefen des aktuellen Zeitschrittes auf events
 #define J_EPS_DIST 0.05// [m]
-#define J_EPS_INFO_DIST 2.0 // [m] abstand für Informationsaustausch (GraphRouter)
-#define J_EPS_GOAL 0.005 // [m] Abstand zum Ziel, damit Fußgänger immer zu einem Raum gehört
-#define J_TOLERANZ 0.03  // [m] Toleranz beim erstellen der Linien
-#define J_EPS_V 0.1 // [m/s] wenn  v<EPS_V wird mit 0 gerechnet
 
+#define J_EPS_GOAL 0.005 /// [m] Abstand zum Ziel, damit Fußgänger immer zu einem Raum gehört
+#define J_TOLERANZ 0.03  /// [m] Toleranz beim erstellen der Linien
+#define J_EPS_V 0.1 /// [m/s] wenn  v<EPS_V wird mit 0 gerechnet
 
-#define JPS_VERSION "0.5"
-#define JPS_VERSION_MINOR 5
-#define JPS_VERSION_MAJOR 0
+// routing macros
+#define J_QUEUE_VEL_THRESHOLD_NEW_ROOM 0.7 // [m/s] maximum speed to be considered in a queue while looking for a reference in a new room
+#define J_QUEUE_VEL_THRESHOLD_JAM 0.2 // [m/s] maximum speed to be considered in a queue while looking for a reference in a jam situation
+#define CBA_THRESHOLD 0.15
+#define OBSTRUCTION 4
 
-// Länge von char vectoren zur Ausgabe
+// Length of array
 #define CLENGTH 1000
 
-
-// Faktor für TraVisTo (cm <-> m)
+// conversion (cm <-> m)
 #define FAKTOR 100
 
-
-// final destinations for the pedestrians
-#define FINAL_DEST_OUT -1 //default
-
-
-//routing
-#define J_EPS_HL_DIST 0.012
-#define J_EPS_AP_DIST J_EPS_GOAL+J_EPS_HL_DIST
+// default final destination for the pedestrians
+#define FINAL_DEST_OUT -1
 
 // Linked cells
-#define LIST_EMPTY 	-1
+#define LIST_EMPTY      -1
 
 
 enum RoomState {
-    ROOM_CLEAN=0,
-    ROOM_SMOKED=1,
+     ROOM_CLEAN=0,
+     ROOM_SMOKED=1
+};
+
+enum AgentType {
+     MALE=0,
+     FEMALE,
+     CHILD,
+     ELDERLY
 };
 
 enum FileFormat {
-    FORMAT_XML_PLAIN,
-    FORMAT_XML_BIN,
-    FORMAT_PLAIN,
-    FORMAT_VTK,
-    FORMAT_XML_PLAIN_WITH_MESH
+     FORMAT_XML_PLAIN,
+     FORMAT_XML_BIN,
+     FORMAT_PLAIN,
+     FORMAT_VTK,
+     FORMAT_XML_PLAIN_WITH_MESH
 };
 
 enum RoutingStrategy {
-    ROUTING_LOCAL_SHORTEST,
-    ROUTING_GLOBAL_SHORTEST,
-    ROUTING_QUICKEST,
-    ROUTING_DYNAMIC,
-    ROUTING_FROM_FILE,
-    ROUTING_NAV_MESH,
-    ROUTING_DUMMY,
-    ROUTING_SAFEST,
-    ROUTING_UNDEFINED =-1
+     ROUTING_LOCAL_SHORTEST=1,
+     ROUTING_GLOBAL_SHORTEST,
+     ROUTING_QUICKEST,
+     ROUTING_FROM_FILE,
+     ROUTING_NAV_MESH,
+     ROUTING_DUMMY,
+     ROUTING_SAFEST,
+     ROUTING_COGNITIVEMAP,
+     ROUTING_UNDEFINED =-1
 };
 
+enum OperativModels {
+    MODEL_GFCM=1,
+    MODEL_GOMPERTZ,
+//    MODEL_ORCA,
+//    MODEL_CFM,
+//    MODEL_VELO
+//    MODEL_GNM
+};
 
+enum AgentColorMode {
+     BY_VELOCITY=1,
+     BY_KNOWLEDGE,
+     BY_ROUTE,
+     BY_SPOTLIGHT
+};
 //global functions for convenience
 
-inline char    xmltob(const char * t,char    v=0)
+inline char xmltob(const char * t, char v = 0)
+{
+     if (t && (*t)) return (char) atoi(t);
+     return v;
+}
+inline int xmltoi(const char * t, int v = 0)
 {
-    if (t&&(*t)) return (char)atoi(t);
-    return v;
+     if (t && (*t)) return atoi(t);
+     return v;
 }
-inline int     xmltoi(const char * t,int     v=0)
+inline long xmltol(const char * t, long v = 0)
 {
-    if (t&&(*t)) return atoi(t);
-    return v;
+     if (t && (*t)) return atol(t);
+     return v;
 }
-inline long    xmltol(const char * t,long    v=0)
+inline double xmltof(const char * t, double v = 0.0)
 {
-    if (t&&(*t)) return atol(t);
-    return v;
+     if (t && (*t)) return atof(t);
+     return v;
 }
-inline double  xmltof(const char * t,double  v=0.0)
+inline const char * xmltoa(const char * t, const char * v = "")
 {
-    if (t&&(*t)) return atof(t);
-    return v;
+     if (t) return t;
+     return v;
 }
-inline const char * xmltoa(const char * t,      const char * v="")
+inline char xmltoc(const char * t, const char v = '\0')
 {
-    if (t)       return  t;
-    return v;
+     if (t && (*t)) return *t;
+     return v;
+}
+
+/**
+ * @return true if the element is present in the vector
+ */
+template<typename A>
+inline bool IsElementInVector(const std::vector<A> &vec, A& el) {
+     typename std::vector<A>::const_iterator it;
+     it = std::find (vec.begin(), vec.end(), el);
+     if(it==vec.end()) {
+          return false;
+     } else {
+          return true;
+     }
+}
+
+/**
+ * Implementation of a map with a default value.
+ * @return the default value if the element was not found in the map
+ */
+template <typename K, typename V>
+inline V GetWithDef(const  std::map <K,V> & m, const K & key, const V & defval ) {
+     typename std::map<K,V>::const_iterator it = m.find( key );
+     if ( it == m.end() ) {
+          return defval;
+     } else {
+          return it->second;
+     }
+}
+
+inline std::string concatenate(std::string const& name, int i) {
+     std::stringstream s;
+     s << name << i;
+     return s.str();
 }
-inline char xmltoc(const char * t,const char v='\0')
+
+//**************************************************************
+//useful colors attributes for debugging
+//**************************************************************
+
+//Text attributes
+#define OFF       0     //All attributes off
+#define BRIGHT      1    //Bold on
+//       4    Underscore (on monochrome display adapter only)
+#define BLINK       5    //Blink on
+//       7    Reverse video on
+//      8    Concealed on
+
+//   Foreground colors
+#define BLACK     30
+#define CYAN      36
+#define WHITE     37
+#define RED       31
+#define GREEN     32
+#define YELLOW    33
+#define BLUE      34
+#define MAGENTA   35
+
+//    Background colors
+#define BG_BLACK  40
+#define BG_RED    41
+#define BG_GREEN  42
+#define BG_YELLOW 43
+#define BG_BLUE   44
+#define BG_CYAN   47
+#define BG_WHITE  47
+
+// Special caracters
+#define HOME  printf("\033[1;1H");  // cursor up left
+#define CLEAR   printf(" \033[2J"); //clear screen
+#define RED_LINE  printf("%c[%d;%d;%dm\n",0x1B, BRIGHT,RED,BG_BLACK);
+#define GREEN_LINE  printf("\t%c[%d;%d;%dm",0x1B, BRIGHT,GREEN,BG_BLACK);
+#define BLUE_LINE  printf("\t%c[%d;%d;%dm",0x1B, BRIGHT,BLUE,BG_BLACK);
+#define MAGENTA_LINE  printf("\t%c[%d;%d;%dm",0x1B, BRIGHT,MAGENTA,BG_BLACK);
+#define YELLOW_LINE  printf("\t%c[%d;%d;%dm",0x1B, BRIGHT,YELLOW,BG_BLACK);
+#define OFF_LINE printf("%c[%dm\n", 0x1B, OFF);
+
+
+//**************************************************************
+//useful macros  for debugging
+//**************************************************************
+#ifdef TRACE_LOGGING
+
+inline void _printDebugLine(const std::string& fileName, int lineNumber)
 {
-    if (t&&(*t)) return *t;
-    return v;
+unsigned found = fileName.find_last_of("/\\");
+std::cerr  << "["<< lineNumber  << "]: ---"<< fileName.substr(found+1)<< " ---"<<std::endl;
 }
 
-#endif	/* _MACROS_H */
+#define dtrace(...)                         \
+    (_printDebugLine(__FILE__, __LINE__),   \
+    fprintf(stderr, __VA_ARGS__),           \
+    (void) fprintf(stderr, "\n"))
+
+#define derror(...)                         \
+    (_printDebugLine(__FILE__, __LINE__),   \
+    fprintf(stderr, "ERROR: "),             \
+    fprintf(stderr, __VA_ARGS__)            \
+    )
+#else
+
+#define dtrace(...)    ((void) 0)
+#define derror(...)                         \
+    (fprintf(stderr, __VA_ARGS__)           \
+    )
+#endif /* TRACE_LOGGING */
 
+#endif  /* _MACROS_H */
diff --git a/src/geometry/Building.cpp b/src/geometry/Building.cpp
index f4e7d06ea05bf4c38f685dc136f8e250206f0dfb..6e8cf45d4f704850cc8ed1e185464e9ce15e18ed 100644
--- a/src/geometry/Building.cpp
+++ b/src/geometry/Building.cpp
@@ -1,7 +1,7 @@
 /**
  * \file        Building.cpp
  * \date        Oct 1, 2014
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -34,8 +34,9 @@
 #ifdef _SIMULATOR
 #include "../pedestrian/Pedestrian.h"
 #include "../mpi/LCGrid.h"
-#include "../routing/RoutingEngine.h"
 #include "../routing/SafestPathRouter.h"
+#include "../routing/RoutingEngine.h"
+#include "../pedestrian/PedDistributor.h"
 #endif
 
 //#undef _OPENMP
@@ -49,10 +50,6 @@
 
 using namespace std;
 
-/************************************************************
- Konstruktoren
- ************************************************************/
-
 
 Building::Building()
 {
@@ -60,11 +57,32 @@ Building::Building()
      _projectFilename = "";
      _geometryFilename= "";
      _rooms = vector<Room*>();
-     _routingEngine = NULL;
-     _linkedCellGrid = NULL;
+     _routingEngine = nullptr;
+     _linkedCellGrid = nullptr;
      _savePathway = false;
 }
 
+#ifdef _SIMULATOR
+Building::Building(const std::string& filename, const std::string& rootDir, RoutingEngine& engine, PedDistributor& distributor, double linkedCellSize)
+        :_projectFilename(filename), _projectRootDir(rootDir), _routingEngine(&engine)
+{
+     _caption = "no_caption";
+     _rooms = vector<Room*>();
+     _savePathway = false;
+     _linkedCellGrid = nullptr;
+
+     //todo: what happens if any of these  methods failed (return false)? throw exception ?
+     this->LoadGeometry();
+     this->LoadRoutingInfo(filename);
+     this->AddSurroundingRoom();
+     this->InitGeometry();
+     this->LoadTrafficInfo();
+     distributor.Distribute(this);
+     this->InitGrid(linkedCellSize);
+     _routingEngine->Init(this);
+     this->SanityCheck();
+}
+#endif //Simulator
 
 Building::~Building()
 {
@@ -162,12 +180,12 @@ Room* Building::GetRoom(int index) const
      } else {
           Log->Write("ERROR: Wrong 'index' in CBuiling::GetRoom() Room ID: %d size: %d",index, _rooms.size());
           Log->Write("\tControl your rooms ID and make sure they are in the order 0, 1, 2,.. ");
-          exit(EXIT_FAILURE);
+          //exit(EXIT_FAILURE);
+          return NULL;
      }
 }
 
 
-
 LCGrid* Building::GetGrid() const
 {
      return _linkedCellGrid;
@@ -260,9 +278,11 @@ void Building::AddSurroundingRoom()
 
 bool Building::InitGeometry()
 {
+     int r;
+     unsigned int i;
      Log->Write("INFO: \tInit Geometry");
-     for (int i = 0; i < GetNumberOfRooms(); i++) {
-          Room* room = GetRoom(i);
+     for (r = 0; r < GetNumberOfRooms(); r++) {
+          Room* room = GetRoom(r);
           // Polygone berechnen
           for (int j = 0; j < room->GetNumberOfSubRooms(); j++) {
                SubRoom* s = room->GetSubRoom(j);
@@ -272,13 +292,13 @@ bool Building::InitGeometry()
 
                //  crossings
                const vector<Crossing*>& crossings = s->GetAllCrossings();
-               for (unsigned int i = 0; i < crossings.size(); i++) {
+               for (i = 0; i < crossings.size(); i++) {
                     goals.push_back(crossings[i]);
                }
 
                // and  transitions
                const vector<Transition*>& transitions = s->GetAllTransitions();
-               for (unsigned int i = 0; i < transitions.size(); i++) {
+               for (i = 0; i < transitions.size(); i++) {
                     goals.push_back(transitions[i]);
                }
 
@@ -420,13 +440,16 @@ bool Building::LoadGeometry(const std::string &geometryfile)
 
 
                string subroom_id = xmltoa(xSubRoom->Attribute("id"), "-1");
-               string closed = xmltoa(xSubRoom->Attribute("closed"), "0");
+               string SubroomClosed = xmltoa(xSubRoom->Attribute("closed"), "0");
                string type = xmltoa(xSubRoom->Attribute("class"),"subroom");
 
                //get the equation of the plane if any
                double A_x = xmltof(xSubRoom->Attribute("A_x"), 0.0);
                double B_y = xmltof(xSubRoom->Attribute("B_y"), 0.0);
+
+               // assume either the old "C_z" or the new "C"
                double C_z = xmltof(xSubRoom->Attribute("C_z"), 0.0);
+               C_z = xmltof(xSubRoom->Attribute("C"), C_z);
 
                SubRoom* subroom = NULL;
 
@@ -480,13 +503,13 @@ bool Building::LoadGeometry(const std::string &geometryfile)
 
                     int id = xmltof(xObstacle->Attribute("id"), -1);
                     int height = xmltof(xObstacle->Attribute("height"), 0);
-                    double closed = xmltof(xObstacle->Attribute("closed"), 0);
-                    string caption = xmltoa(xObstacle->Attribute("caption"),"-1");
+                    double ObstClosed = xmltof(xObstacle->Attribute("closed"), 0);
+                    string ObstCaption = xmltoa(xObstacle->Attribute("caption"),"-1");
 
                     Obstacle* obstacle = new Obstacle();
                     obstacle->SetId(id);
-                    obstacle->SetCaption(caption);
-                    obstacle->SetClosed(closed);
+                    obstacle->SetCaption(ObstCaption);
+                    obstacle->SetClosed(ObstClosed);
                     obstacle->SetHeight(height);
 
                     //looking for polygons (walls)
@@ -678,7 +701,7 @@ void Building::AddHline(Hline* line)
           // check if the lines are identical
           Hline* ori= _hLines[line->GetID()];
           if(ori->operator ==(*line)) {
-               Log->Write("INFO: Skipping identical hlines with ID [%d]",line->GetID());
+               Log->Write("INFO: \tSkipping identical hlines with ID [%d]",line->GetID());
                return;
           } else {
                Log->Write(
@@ -768,11 +791,11 @@ Goal* Building::GetFinalGoal(int ID)
 
 Crossing* Building::GetTransOrCrossByName(string caption) const
 {
-
      {
           //eventually
           map<int, Transition*>::const_iterator itr;
-          for(itr = _transitions.begin(); itr != _transitions.end(); ++itr) {
+          for(itr = _transitions.begin(); itr != _transitions.end(); ++itr)
+          {
                if (itr->second->GetCaption() == caption)
                     return itr->second;
           }
@@ -780,7 +803,8 @@ Crossing* Building::GetTransOrCrossByName(string caption) const
      {
           //finally the  crossings
           map<int, Crossing*>::const_iterator itr;
-          for(itr = _crossings.begin(); itr != _crossings.end(); ++itr) {
+          for(itr = _crossings.begin(); itr != _crossings.end(); ++itr)
+          {
                if (itr->second->GetCaption() == caption)
                     return itr->second;
           }
@@ -795,7 +819,8 @@ Hline* Building::GetTransOrCrossByUID(int id) const
      {
           //eventually transitions
           map<int, Transition*>::const_iterator itr;
-          for(itr = _transitions.begin(); itr != _transitions.end(); ++itr) {
+          for(itr = _transitions.begin(); itr != _transitions.end(); ++itr)
+          {
                if (itr->second->GetUniqueID()== id)
                     return itr->second;
           }
@@ -803,19 +828,21 @@ Hline* Building::GetTransOrCrossByUID(int id) const
      {
           //then the  crossings
           map<int, Crossing*>::const_iterator itr;
-          for(itr = _crossings.begin(); itr != _crossings.end(); ++itr) {
+          for(itr = _crossings.begin(); itr != _crossings.end(); ++itr)
+          {
                if (itr->second->GetUniqueID() == id)
                     return itr->second;
           }
      }
      {
           //finally the  hlines
-          for(auto itr = _hLines.begin(); itr != _hLines.end(); ++itr) {
+          for(auto itr = _hLines.begin(); itr != _hLines.end(); ++itr)
+          {
                if (itr->second->GetUniqueID() == id)
                     return itr->second;
           }
      }
-     Log->Write("WARNING: No Transition or Crossing or hline with ID %d: " ,id);
+     Log->Write("ERROR: No Transition or Crossing or hline with ID %d: " ,id);
      return NULL;
 }
 
@@ -1154,7 +1181,7 @@ void Building::AddPedestrian(Pedestrian* ped)
      _allPedestians.push_back(ped);
 }
 
-void Building::GetPedestrians(int room, int subroom, std::vector<Pedestrian*>& peds)
+void Building::GetPedestrians(int room, int subroom, std::vector<Pedestrian*>& peds) const
 {
      for(unsigned int p = 0;p<_allPedestians.size();p++){
           Pedestrian* ped=_allPedestians[p];
@@ -1225,11 +1252,6 @@ Pedestrian* Building::GetPedestrian(int pedID) const
      return NULL;
 }
 
-int Building::GetNumberOfPedestrians() const
-{
-     return _allPedestians.size();
-}
-
 Transition* Building::GetTransitionByUID(int uid) const
 {
      //eventually
@@ -1358,6 +1380,7 @@ bool Building::SaveGeometry(const std::string &filename)
      if(geofile.is_open())
      {
           geofile<<geometry.str();
+          Log->Write("INFO:\tfile saved to %s",filename.c_str());
      }
      else
      {
@@ -1369,3 +1392,5 @@ bool Building::SaveGeometry(const std::string &filename)
 }
 
 #endif // _SIMULATOR
+
+
diff --git a/src/geometry/Building.h b/src/geometry/Building.h
index 006ae966b2d6c7aea56a18efc62f774ad002138e..932fb93e209ba05daff3f68ae4e047931aa57ed9 100644
--- a/src/geometry/Building.h
+++ b/src/geometry/Building.h
@@ -1,7 +1,7 @@
 /**
  * \file        Building.h
  * \date        Oct 1, 2010
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -47,17 +47,19 @@ class Pedestrian;
 class Transition;
 class LCGrid;
 class ForceModel;
+class PedDistributor;
 
 
-class Building {
+class Building
+{
 private:
-
      std::string _caption;
      std::string _projectFilename;
      std::string _projectRootDir;
      std::string _geometryFilename;
      RoutingEngine* _routingEngine;
      LCGrid* _linkedCellGrid;
+     //TODO: change the type to (unorder) map <int , Room*>
      std::vector<Room*> _rooms;
      std::vector<Pedestrian*> _allPedestians;
 
@@ -73,10 +75,10 @@ private:
 public:
      /// constructor
      Building();
+     Building(const std::string&, const std::string&, RoutingEngine&, PedDistributor&, double);
      /// destructor
      virtual ~Building();
 
-
      void SetCaption(const std::string& s);
      void SetRoutingEngine(RoutingEngine* r);
      void SetRoom(Room* room, int index);
@@ -85,8 +87,7 @@ public:
      void DeletePedestrian(Pedestrian* &ped);
      /// delete the ped from the simulation
      void AddPedestrian(Pedestrian* ped);
-     void GetPedestrians(int room, int subroom, std::vector<Pedestrian*>& peds);
-
+     void GetPedestrians(int room, int subroom, std::vector<Pedestrian*>& peds) const;
 
      std::string GetCaption() const;
      RoutingEngine* GetRoutingEngine() const;
@@ -132,21 +133,18 @@ public:
       */
      bool IsVisible(const Point& p1, const Point& p2, bool considerHlines=false);
 
-
      /**
       * @return a crossing or a transition matching the given caption.
       * Return NULL if none is found
       */
      Crossing* GetTransOrCrossByName(std::string caption) const;
 
-
      /**
       * @return a crossing or a transition or a hline matching the given uid.
       * Return NULL if none is found
       */
      Hline* GetTransOrCrossByUID(int uid) const;
 
-
      /**
       * @return the transition matching the uid
       */
@@ -155,8 +153,6 @@ public:
      //TOD0: rename later to GetGoal
      Goal* GetFinalGoal(int id);
 
-     int GetNumberOfPedestrians() const;
-
      /**
       * @return the linked-cell grid used for spatial query
       */
diff --git a/src/geometry/Crossing.cpp b/src/geometry/Crossing.cpp
index c75a29d035512c0934333a9f9c43a5e4181a3384..f4ce45a108009cbdf2a99601c5527ad0442b35b2 100644
--- a/src/geometry/Crossing.cpp
+++ b/src/geometry/Crossing.cpp
@@ -1,7 +1,7 @@
 /**
  * \file        Crossing.cpp
  * \date        Nov 16, 2010
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -39,58 +39,28 @@ Crossing::Crossing()
      _room1 = NULL;
      _subRoom1 = NULL;
      _subRoom2 = NULL;
-     _caption = "";
 }
 
 Crossing::~Crossing()
 {
 }
 
-
 void Crossing::SetID(int ID)
 {
      _id = ID;
 }
 
-void Crossing::SetRoom1(Room* r)
-{
-     _room1 = r;
-}
-
-void Crossing::SetSubRoom1(SubRoom* r1)
-{
-     _subRoom1 = r1;
-}
-
 void Crossing::SetSubRoom2(SubRoom* r2)
 {
      _subRoom2 = r2;
 }
 
-void Crossing::SetCaption(string s)
-{
-     _caption = s;
-}
 // Getter-Funktionen
 
 int Crossing::GetID() const
 {
      return _id;
 }
-string Crossing::GetCaption() const
-{
-     return _caption;
-}
-Room* Crossing::GetRoom1() const
-{
-     return _room1;
-}
-
-
-SubRoom* Crossing::GetSubRoom1() const
-{
-     return _subRoom1;
-}
 
 SubRoom* Crossing::GetSubRoom2() const
 {
@@ -115,13 +85,6 @@ bool Crossing::IsTransition() const
      return false;
 }
 
-
-bool Crossing::IsInRoom(int roomID) const
-{
-     return _room1->GetID() == roomID;
-}
-
-
 bool Crossing::IsInSubRoom(int subroomID) const
 {
      bool r1, r2;
@@ -154,7 +117,6 @@ SubRoom* Crossing::GetOtherSubRoom(int roomID, int subroomID) const
 
 
 // Ausgabe
-
 void Crossing::WriteToErrorLog() const
 {
      string s;
@@ -169,7 +131,7 @@ void Crossing::WriteToErrorLog() const
 }
 
 // TraVisTo Ausgabe
-string Crossing::WriteElement() const
+string Crossing::GetDescription() const
 {
      //return "";
      string geometry;
diff --git a/src/geometry/Crossing.h b/src/geometry/Crossing.h
index 77d066fc24461087b0d417fb3f89ec38020e79dd..a2802b32be74fe270f57c5118ebc0e3c55e8cc10 100644
--- a/src/geometry/Crossing.h
+++ b/src/geometry/Crossing.h
@@ -1,7 +1,7 @@
 /**
  * \file        Crossing.h
  * \date        Nov 16, 2010
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -38,11 +38,10 @@ class SubRoom;
 
 class Crossing : public Hline {
 private:
-     /// ? unique between crossings and transitions ?
+     /// TODO ? unique between crossings and transitions ?
      int _id;
      /// only one room needed, since a crossing only separates 2 subrooms
      Room* _room1;
-     std::string _caption;
      SubRoom* _subRoom1;
      SubRoom* _subRoom2;
 
@@ -60,41 +59,11 @@ public:
       */
      int GetID () const;
 
-     /**
-      * Set/Get the first room
-      */
-     void SetRoom1(Room* r);
-
-     /**
-      * Set/Get the crossing caption
-      */
-     void SetCaption(std::string s);
-
-     /**
-      * Set/Get the first subroom
-      */
-     void SetSubRoom1(SubRoom* r1);
-
      /**
       * Set/Get the second subroom
       */
      void SetSubRoom2(SubRoom* r2);
 
-     /**
-      * Set/Get the crossing caption
-      */
-     std::string GetCaption() const;
-
-     /**
-      * Set/Get the first room
-      */
-     Room* GetRoom1() const;
-
-     /**
-      * Set/Get the first subroom
-      */
-     SubRoom* GetSubRoom1() const;
-
      /**
       * Set/Get the second subroom
       */
@@ -105,7 +74,6 @@ public:
       */
      bool IsInSubRoom(int subroomID) const;
 
-
      /**
       * @return true if the crossing is open = passable
       */
@@ -123,11 +91,6 @@ public:
       */
      virtual bool IsTransition() const;
 
-     /**
-      * @return true if the crossing/transintion/hline is associated with the room
-      */
-     virtual bool IsInRoom(int roomID) const;
-
      /**
       * @return the other subroom not matching the data
       */
@@ -141,7 +104,7 @@ public:
      /**
       * @return a nicely formatted string representation of the object
       */
-     virtual std::string WriteElement() const;
+     virtual std::string GetDescription() const;
 };
 
 #endif  /* _CROSSING_H */
diff --git a/src/geometry/Goal.cpp b/src/geometry/Goal.cpp
index a2157819a0986f834920bb0c822049feac9bb44d..ff6c2705b03062d4478569e2fdcf2e99163f0fe5 100644
--- a/src/geometry/Goal.cpp
+++ b/src/geometry/Goal.cpp
@@ -1,7 +1,7 @@
 /**
  * \file        Goal.cpp
  * \date        Spe 12, 2013
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
diff --git a/src/geometry/Goal.h b/src/geometry/Goal.h
index 3fe6596f0883d589b238b74e97d6c5acbf7e9d42..cdd335e8105d71dec242538267508c33dd5914ba 100644
--- a/src/geometry/Goal.h
+++ b/src/geometry/Goal.h
@@ -1,7 +1,7 @@
 /**
  * \file        Goal.h
  * \date        Sep 12, 2013
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
diff --git a/src/geometry/Hline.cpp b/src/geometry/Hline.cpp
index a88a5dd69b7ce564da5ed932a00257f09f7fb9e6..795d685220ade115fd8db8e96b888f361cc89718 100644
--- a/src/geometry/Hline.cpp
+++ b/src/geometry/Hline.cpp
@@ -1,7 +1,7 @@
 /**
  * \file        Hline.cpp
  * \date        Aug 1, 2012
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -106,12 +106,11 @@ void Hline::WriteToErrorLog() const
 }
 
 // TraVisTo Ausgabe
-
-string Hline::WriteElement() const
+string Hline::GetDescription() const
 {
      string geometry;
      char tmp[CLENGTH] = "";
-     sprintf(tmp,"\t\t<hline ID=\"%d\" color = \"250\" caption=\"%d_%d\">\n",GetUniqueID(),GetID(),GetUniqueID());
+     sprintf(tmp,"\t\t<hline ID=\"%d\" color = \"250\" caption=\"h_%d_%d\">\n",GetUniqueID(),GetID(),GetUniqueID());
      geometry.append(tmp);
      //geometry.append("\t\t<door color=\"250\">\n");
      sprintf(tmp, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\" zPos=\"%.2f\"/>\n",
@@ -127,5 +126,3 @@ string Hline::WriteElement() const
      geometry.append("\t\t</hline>\n");
      return geometry;
 }
-
-
diff --git a/src/geometry/Hline.h b/src/geometry/Hline.h
index fb42a23e0bcdfb2371a3e32d07da0de9d54ad10b..e2c2b8cf0a11bbf54020720cc41a027fde020272 100644
--- a/src/geometry/Hline.h
+++ b/src/geometry/Hline.h
@@ -1,7 +1,7 @@
 /**
  * \file        Hline.h
  * \date        Aug 1, 2012
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -68,7 +68,6 @@ public:
       */
      void SetSubRoom1(SubRoom* r);
 
-
      /**
       * Set/Get the id of the line
       */
@@ -77,7 +76,7 @@ public:
      /**
       * Set/Get the line caption
       */
-     std::string GetCaption() const;
+     virtual std::string GetCaption() const;
 
      /**
       * Set/Get the Room containing this line
@@ -89,16 +88,15 @@ public:
       */
      SubRoom* GetSubRoom1() const;
 
-
      /**
       * @return true if the line is in the given subroom
       */
-     bool IsInSubRoom(int subroomID) const;
+     virtual bool IsInSubRoom(int subroomID) const;
 
      /**
       * @return true if the line is in the given room
       */
-     bool IsInRoom(int roomID) const;
+     virtual bool IsInRoom(int roomID) const;
 
      /**
       * Debug output
@@ -108,7 +106,7 @@ public:
      /**
       * @return a nicely formatted string representation of the object
       */
-     virtual std::string WriteElement() const;
+     virtual std::string GetDescription() const;
 };
 
 #endif /* HLINE_H_ */
diff --git a/src/geometry/Line.cpp b/src/geometry/Line.cpp
index b987e90f326e22a6209fefbd6399dcf679178283..0ed90c3e14cad08125da2508c520ac0488628a65 100644
--- a/src/geometry/Line.cpp
+++ b/src/geometry/Line.cpp
@@ -1,7 +1,7 @@
 /**
  * \file        Line.cpp
  * \date        Sep 30, 2010
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -306,12 +306,13 @@ bool Line::operator==(const Line& l) const
 }
 
 /* Zwei Linien sind ungleich, wenn ihre beiden Punkte
- * ungleich sind
+ * ungleich sind.
+ * TODO: check this
  * */
 bool Line::operator!=(const Line& l) const
 {
-     return ((_point1 != l.GetPoint1() && _point2 != l.GetPoint2()) &&
-             (_point2 != l.GetPoint1() && _point1 != l.GetPoint2()));
+     return (! this->operator ==(l) );
+
 }
 
 double Line::Length() const
@@ -373,6 +374,15 @@ bool Line::IntersectionWith(const Line& l) const
      return true;
 }
 
+Line Line::enlarge(double d) const
+{
+     const Point& p1 = _point1;
+     const Point& p2 = _point2;
+     Point diff = (p1 - p2).Normalized() * d;
+
+     return Line(p1 + diff, p2 - diff);
+}
+
 bool Line::IsHorizontal()
 {
      return fabs (_point1._y-_point2._y ) <= J_EPS;
@@ -515,7 +525,7 @@ std::string Line::toString() const
 //insteed of a boolian
 double Line::GetIntersectionDistance(const Line & l) const
 {
-
+#define DEBUG 0
      double deltaACy = _point1.GetY() - l.GetPoint1().GetY();
      double deltaDCx = l.GetPoint2().GetX() - l.GetPoint1().GetX();
      double deltaACx = _point1.GetX() - l.GetPoint1().GetX();
@@ -555,152 +565,79 @@ double Line::GetIntersectionDistance(const Line & l) const
      }
 
      Point PointF = Point ((float) (_point1._x + r * deltaBAx), (float) (_point1._y + r * deltaBAy));
+     if(!IsInLineSegment(PointF)) //is point on the line?
+          return infinity; 
      double dist = (_point1-PointF).NormSquare();
-     //cout<< " MC Line.cpp 516" << l.toString() << " intersects with " << toString() <<endl;
-     //cout<<" at point " << PointF.toString()<<endl;
-     //cout <<  "distance is "<< sqrt(dist)<< "... return "<< dist<<endl;
+#if DEBUG
+     printf("Enter GetIntersection\n");
+     cout<< "\t" << l.toString() << " intersects with " << toString() <<endl;
+     cout<<"\t at point " << PointF.toString()<<endl;
+     cout <<  "\t\t --> distance is "<< sqrt(dist)<< "... return "<< dist<<endl;
+     printf("Leave GetIntersection\n");
+#endif
      return dist;
 
 }
-//sign of the angle depends on the direction of the wall (l).
-//the second point of l should be the nearest to the goal.
-//the goal in the intended use case is the second point of
-//the calling line
-//
-double Line::GetAngle(const Line & l) const
-{
-     const double pi= atan(1)*4;
-     double ax = _point1.GetX();
-     double ay = _point1.GetY();
-     double bx = _point2.GetX();
-     double by = _point2.GetY();
-     //printf("ax=%f, ay=%f --- bx=%f, by=%f\n", ax, ay, bx, by);
-     double diff_x1 = bx - ax;
-     double diff_y1 = by - ay;
-     // printf("diff_x1=%f, diff_y1=%f\n", diff_x1, diff_y1);
-     double cx =l.GetPoint1().GetX();
-     double cy =l.GetPoint1().GetY();
-     double dx =l.GetPoint2().GetX();
-     double dy =l.GetPoint2().GetY();
-     //printf("cx=%f, cy=%f --- dx=%f, dy=%f\n", cx, cy, dx, dy);
-
-     double diff_x2 = dx - cx;
-     double diff_y2 = dy - cy;
-     //  printf("diff_x2=%f, diff_y2=%f\n", diff_x2, diff_y2);
-
-     double atanA = atan2( diff_y1, diff_x1 );
-     double atanB = atan2( diff_y2, diff_x2);
-
-//    printf("atanA %f atanB %f\n", atanA*180/pi, atanB*180/pi);
-     double angle = atanA - atanB;
-
-
-     double absAngle= fabs(angle);
-     double sign = (angle <0)? -1.0 : 1.0;
-
-
-     // if (angle>pi)
-     //     printf( "NORMALIZE --> %.2f\n", (2*pi-angle)*180/pi);
-     angle = (angle>pi)? -(2*pi-absAngle): angle;
-     //printf("angle=%.2f, absAngle=%.2f, sign=%.1f\n", angle*180/pi, absAngle, sign);
-
-     absAngle= fabs(angle);
-     double  tmp = (absAngle<pi/2)? (-angle) : (pi-absAngle)*sign;
-
-     //printf("tmp=%.2f exp=%.2f\n", tmp, (pi-absAngle)*sign);
-
-     // 3pi/4  ---->  pi/4 (sign=1)
-     // -3pi/4 ----> -pi/4 (sign=-1)
-     // pi/4   ----> -pi/4
-     // -pi/4   ----> pi/4
 
-     return tmp;
+// calculates the angles QPF and QPL 
+// return the snagle of the point (F or L) which is nearer to the Goal 
+//the calling line: P->Q, Q is the crossing point
+// 
+//                 o P 
+//                / 
+//               /  
+//   F          /              L 
+//   o --------x---------------o  
+//            / Q
+//           /
+//          o Goal
 
+double Line::GetDeviationAngle(const Line & l) const
+{
+     // const double PI = 3.14159258;
+#define DEBUG 0
+     Point P = _point1;
+     Point Goal = _point2;
 
+     Point L = l._point1;
+     Point R = l._point2;
+     
+     double dist_Goal_L = (Goal-L).NormSquare();
+     double dist_Goal_R = (Goal-R).NormSquare();
+     
+     double angle, angleL, angleR;
+     // we don't need to calculate both angles, but for debugging purposes we do it.
+     angleL = atan((Goal-P).CrossP(L-P)/(Goal-P).ScalarP(L-P));
+     angleR = atan((Goal-P).CrossP(R-P)/(Goal-P).ScalarP(R-P));
 
-     //  double distPoint2ToGoalSq = (dx-bx)*(dx-bx) + (dy-by)*(dy-by);
-     //  double distPoint1ToGoalSq = (cx-bx)*(cx-bx) + (cy-by)*(cy-by);
-     //  if(distPoint1ToGoalSq < distPoint2ToGoalSq) //invert the line
-     //  {
-     //      double tx = dx, ty = dy;
-     //      dx = cx; dy = cy;
-     //      cx = tx; cy = ty;
-     //  }
+     angle = (dist_Goal_L<dist_Goal_R)?angleL:angleR;
+#if DEBUG
+     printf("Enter GetAngel()\n");
+     printf("\tP=[%f,%f]\n",P.GetX(), P.GetY());
+     printf("\tGoal=[%f,%f]\n",Goal.GetX(), Goal.GetY());
+     printf("\tL=[%f,%f]\n",L.GetX(), L.GetY());
+     printf("\tR=[%f,%f]\n",R.GetX(), R.GetY());
+     printf("\t\tdist_Goal_L=%f\n",dist_Goal_L);
+     printf("\t\tdist_Goal_R=%f\n",dist_Goal_R);
+     printf("\t\t --> angleL=%f\n",angleL);
+     printf("\t\t --> angleR=%f\n",angleR);
+     printf("\t\t --> angle=%f\n",angle);
+     printf("Leave GetAngel()\n");
+#endif
+     return angle;
+}
 
-     //  double dotp = (bx-ax)*(dx-cx)+(by-ay)*(dy-cy);
-     //  double len, len1;
 
-     //  len = l.Length();
-     //  if (len < J_EPS)
-     //      return 0;
 
-     //  len1 = this->Length();
 
-     // if (len1 < J_EPS)
-     //      return 0;
 
 
-     //  double angle = acos( dotp / (len * len1) );
-     //  double crossp = (bx-ax)*(dy-cy) - (by-ay)*(dx-cx);
-     //  double sign = (crossp <0)? -1.0 : 1.0;
 
 
 
-     //  angle = (angle<pi/2)?angle:pi-angle;
-     //  return  angle*sign;
 
-}
 
-// get the angle that is needed to turn a line, so that it
-// doen not intersect the nearest Wall in subroom
-// double Line::GetAngle(SubRoom * subroom) const{
-//     double dist;
-//     int inear = -1;
-//     int iObs = -1;
-//     double minDist = 20001;
-//     //============================ WALLS ===========================
-//     const vector<Wall>& walls = subroom->GetAllWalls();
-//     for (int i = 0; i < subroom->GetNumberOfWalls(); i++) {
-//         dist = tmpDirection.GetIntersectionDistance(walls[i]);
-//         printf("Check wall %d. Dist = %f (%f)\n", i, dist, minDist);
-//         if (dist < minDist)
-//         {
-//             inear = i;
-//             minDist = dist;
-//         }
-//     }//walls
-//     //============================ WALLS ===========================
 
-//     //============================ OBST ===========================
-//     const vector<Obstacle*>& obstacles = subroom->GetAllObstacles();
-//     for(unsigned int obs=0; obs<obstacles.size(); ++obs){
-//         const vector<Wall>& owalls = obstacles[obs]->GetAllWalls();
-//         for (unsigned int i = 0; i < owalls.size(); i++) {
-//             dist = tmpDirection.GetIntersectionDistance(owalls[i]);
-//             printf("Check OBS:obs=%d, i=%d Dist = %f (%f)\n", obs, i, dist, minDist);
-//             if (dist < minDist)
-//             {
-//                 inear = i;
-//                 minDist = dist;
-//                 iObs = obs;
-//             }
-//         }//walls of obstacle
-//     }// obstacles
-//     //============================ OBST ===========================
-// //------------------------------------------------------------------------
-
-//     double angle = 0;
-//     if (inear >= 0)
-//         if(iObs >= 0)
-//         {
-//             const vector<Wall>& owalls = obstacles[iObs]->GetAllWalls();
-//             angle =  tmpDirection.GetAngle(owalls[inear]);
-//         }
-//         else
-//             angle =  tmpDirection.GetAngle(walls[inear]);
 
 
 
-// return angle
-
-// }
diff --git a/src/geometry/Line.h b/src/geometry/Line.h
index 6c9577fbe245e9a05234aca23faf546b3d3f68f4..bf4505edae5f78a2bc893f375dcb07f3fd4584c7 100644
--- a/src/geometry/Line.h
+++ b/src/geometry/Line.h
@@ -1,7 +1,7 @@
 /**
  * \file        Line.h
  * \date        Sep 30, 2010
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -233,10 +233,21 @@ public:
      /**
       * @return the angle between two lines
       */
-     double GetAngle(const Line& l) const;
+     double GetDeviationAngle(const Line& l) const;
      //    double GetAngle(SubRoom s) const;
+     Line enlarge(double d) const; 
 
 };
 
 #endif  /* _LINE_H */
 
+
+
+
+
+
+
+
+
+
+
diff --git a/src/geometry/NavLine.cpp b/src/geometry/NavLine.cpp
index 1e3dfb7c9704a1768466738e4075a6922d440f98..bc5d4982052301ddd275324fdf9458cd089a7c81 100644
--- a/src/geometry/NavLine.cpp
+++ b/src/geometry/NavLine.cpp
@@ -1,7 +1,7 @@
 /**
  * \file        NavLine.cpp
  * \date        Aug 30, 2012
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
diff --git a/src/geometry/NavLine.h b/src/geometry/NavLine.h
index 5db0e19e9694cf2a4c8a52b3d0c0be947cd0d26a..0b3c7dc993de26f97d7828776fd1177f299ff54c 100644
--- a/src/geometry/NavLine.h
+++ b/src/geometry/NavLine.h
@@ -1,7 +1,7 @@
 /**
  * \file        NavLine.h
  * \date        Aug 30, 2012
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
diff --git a/src/geometry/Obstacle.cpp b/src/geometry/Obstacle.cpp
index 93cd9a1b60f0df3a39732f37580c30d8b161bf9d..7daa9ae11e7874d13040d40def5aceb54ee184e6 100644
--- a/src/geometry/Obstacle.cpp
+++ b/src/geometry/Obstacle.cpp
@@ -1,7 +1,7 @@
 /**
  * \file        Obstacle.cpp
  * \date        Jul 31, 2012
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -300,6 +300,22 @@ const Point Obstacle::GetCentroid() const
      return Point (px,py);
 }
 
+bool Obstacle::IsClockwise() const
+{
+     if(_poly.size()<3) {
+          Log->Write("ERROR:\tYou need at least 3 vertices to check for orientation. Subroom ID [%d]");
+          return false;
+          //exit(EXIT_FAILURE);
+     }
+
+     Point vecAB= _poly[1]-_poly[0];
+     Point vecBC= _poly[2]-_poly[1];
+
+     double det=vecAB.Det(vecBC);
+     if(fabs(det)<J_EPS) det=0.0;
+
+     return ( det<=0.0 );
+}
 
 bool Obstacle::IntersectWithLine(const Line& line) const
 {
diff --git a/src/geometry/Obstacle.h b/src/geometry/Obstacle.h
index 9302a9563d1c98ec1f5127487c2da81492cf1c31..fdc9fee3e00ba1e8cf0032b93a9f8164efb3065a 100644
--- a/src/geometry/Obstacle.h
+++ b/src/geometry/Obstacle.h
@@ -1,7 +1,7 @@
 /**
  * \file        Obstacle.h
  * \date        Jul 31, 2012
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -135,6 +135,11 @@ public:
       */
      std::string Write();
 
+     /**
+      * @return true if the polygon is clockwise oriented
+      */
+     bool IsClockwise() const;
+
 private:
      int WhichQuad(const Point& vertex, const Point& hitPos) const;
 
diff --git a/src/geometry/Point.cpp b/src/geometry/Point.cpp
index 00f425cfa910888d609ac65fb07cf98ed36295aa..c8fa246b403cee18c43d67dd6cdec724f47fd1e1 100644
--- a/src/geometry/Point.cpp
+++ b/src/geometry/Point.cpp
@@ -1,7 +1,7 @@
 /**
  * \file        Point.cpp
  * \date        Sep 30, 2010
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -125,6 +125,15 @@ double Point::ScalarP(const Point& v) const
      return _x * v._x + _y * v._y;
 }
 
+// since we have only 2D vectors (may be changed in the future), this function returns a scalar
+// (basically the third component of the vector (0,0,z) )
+double Point::CrossP(const Point& p) const
+{
+     return _x*p.GetY() - _y*p.GetX();
+}
+
+
+
 /// determinant of the square matrix formed by the vectors [ this, v]
 double Point::Det(const Point& v) const
 {
@@ -268,6 +277,16 @@ const Point operator*(const Point& p, double f)
      return Point(p._x * f, p._y * f);
 }
 
+
+// Assignment
+Point& Point::operator+=(const Point& p)
+{
+     _x += p._x;
+     _y += p._y;
+     return *this;
+}
+
+
 // divition with scalar
 const Point operator/(const Point& p, double f)
 {
diff --git a/src/geometry/Point.h b/src/geometry/Point.h
index 92578237d3cabb9a2d31d0f4eb928d3718ca9165..df332e2eb7148fa1402b361a50fd9a375d2ec540 100644
--- a/src/geometry/Point.h
+++ b/src/geometry/Point.h
@@ -1,7 +1,7 @@
 /**
  * \file        Point.h
  * \date        Sep 30, 2010
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -77,6 +77,7 @@ public:
      Point NormalizedMolified() const;
      /// dot product
      double ScalarP(const Point& v) const;
+     double CrossP(const Point& p) const;
      /// determinant of the square matrix formed by the vectors [ this, v]
      double Det(const Point& v) const;
      /// translation and rotation in Ellipse coordinate system
@@ -96,7 +97,8 @@ public:
      bool operator==(const Point& p) const;
      /// not equal
      bool operator!=(const Point& p) const;
-
+     /// Assignement
+     Point& operator+=(const Point& p);
      /// nice formating of the point
      std::string toString() const;
 };
diff --git a/src/geometry/Room.cpp b/src/geometry/Room.cpp
index 75729b721eeabc1a54468d50bccbd6e570f2cb6f..edf3e8af65e0f5452e8e0ae957ca3705fa07e8c0 100644
--- a/src/geometry/Room.cpp
+++ b/src/geometry/Room.cpp
@@ -1,7 +1,7 @@
 /**
  * \file        Room.cpp
  * \date        Sep 30, 2010
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -42,6 +42,7 @@ Room::Room()
 {
      _id = -1;
      _state=ROOM_CLEAN; //smoke-free
+     _egressTime=0;
      _caption = "no room caption";
      _zPos = -1.0;
      _subRooms = vector<SubRoom* > ();
@@ -55,6 +56,7 @@ Room::Room(const Room& orig)
      _zPos = orig.GetZPos();
      _subRooms = orig.GetAllSubRooms();
      _state=orig.GetState();
+     _egressTime=orig.GetEgressTime();
      _outputFile=orig.GetOutputHandler();
 }
 
@@ -72,7 +74,7 @@ void Room::SetID(int ID)
      _id = ID;
 }
 
-void Room::SetCaption(string s)
+void Room::SetCaption(const string& s)
 {
      _caption = s;
 }
@@ -106,7 +108,7 @@ int Room::GetID() const
      return _id;
 }
 
-string Room::GetCaption() const
+const string& Room::GetCaption() const
 {
      return _caption;
 }
@@ -117,6 +119,16 @@ double Room::GetZPos() const
      return _zPos;
 }
 
+double Room::GetEgressTime() const
+{
+     return _egressTime;
+}
+
+void Room::SetEgressTime(double time)
+{
+     _egressTime=time;
+}
+
 int Room::GetNumberOfSubRooms() const
 {
      return _subRooms.size();
@@ -145,7 +157,7 @@ SubRoom* Room::GetSubRoom(int index) const
 
 #endif // _SIMULATOR
 
-RoomState Room::GetState() const
+const RoomState& Room::GetState() const
 {
      return _state;
 }
@@ -160,16 +172,6 @@ void Room::AddSubRoom(SubRoom* r)
      _subRooms.push_back(r);
 }
 
-void Room::DeleteSubRoom(int index)
-{
-     if ((index >= 0) && (index < (int) _subRooms.size()))
-          _subRooms.erase(_subRooms.begin() + index);
-     else {
-          Log->Write("ERROR: Wrong Index in Room::DeleteSubRoom()");
-          exit(0);
-     }
-}
-
 /*************************************************************
  Ein-Ausgabe
  ************************************************************/
@@ -184,8 +186,8 @@ void Room::WriteToErrorLog() const
      Log->Write(s);
      // SubRooms
      for (int i = 0; i < GetNumberOfSubRooms(); i++) {
-          SubRoom* s = GetSubRoom(i);
-          s->WriteToErrorLog();
+          SubRoom*sub = GetSubRoom(i);
+          sub->WriteToErrorLog();
      }
 
 }
diff --git a/src/geometry/Room.h b/src/geometry/Room.h
index e4336f000fd8845e4af42514e37ff592bf504904..dc92e55a1521d1673998f3f9c1504ac096f45b26 100644
--- a/src/geometry/Room.h
+++ b/src/geometry/Room.h
@@ -1,7 +1,7 @@
 /**
  * \file        Room.h
  * \date        Sep 30, 2010
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -52,17 +52,20 @@ private:
      /// room elevation
      double _zPos;
      /// all subrooms/partitions of the room
+     /// TODO: Change the type to (unorder)map <int, SubRoom*>
      std::vector<SubRoom*> _subRooms;
      /// all transitions ids
      std::vector<int> _transitionsIDs;
      /// needed if the trajectories for this room are to be write in a special way
      OutputHandler* _outputFile;
+     /// egress time for this room
+     double _egressTime;
 
 public:
      Room();
      Room(const Room& orig);
-     virtual ~Room();
 
+     virtual ~Room();
 
      /**
       * Set/Get the id of the room which is also used as index
@@ -72,7 +75,7 @@ public:
      /**
       * Set/Get the caption of the room
       */
-     void SetCaption(std::string s);
+     void SetCaption(const std::string& s);
 
      /**
       * Set/Get the elevation of the room
@@ -97,13 +100,23 @@ public:
      /**
       * Set/Get the caption of the room
       */
-     std::string GetCaption() const;
+     const std::string& GetCaption() const;
 
      /**
       * Set/Get the elevation of the room
       */
      double GetZPos() const;
 
+     /**
+      * Set/Get the egress time for this room
+      */
+     double GetEgressTime() const;
+
+     /**
+      * Set/Get the egress time for this room
+      */
+     void SetEgressTime(double time);
+
      /**
       * @return the number of subrooms
       */
@@ -127,18 +140,13 @@ public:
      /**
       * @return the state for this room
       */
-     RoomState GetState()const;
+     const RoomState& GetState()const;
 
      /**
       * Push a new subroom in the vector
       */
      void AddSubRoom(SubRoom* r);
 
-     /**
-      * Delete the subroom at the specified index
-      */
-     void DeleteSubRoom(int index);
-
      /**
       * Add a new transition id
       */
diff --git a/src/geometry/SubRoom.cpp b/src/geometry/SubRoom.cpp
index 557301e8f74228f429c7496090ebcf98a7270a8a..830f9728380de0986c65df5082143ed2ea3053b3 100644
--- a/src/geometry/SubRoom.cpp
+++ b/src/geometry/SubRoom.cpp
@@ -1,7 +1,7 @@
 /**
  * \file        SubRoom.cpp
  * \date        Oct 8, 2010
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -82,7 +82,6 @@ SubRoom::~SubRoom()
      _obstacles.clear();
 }
 
-// Setter -Funktionen
 
 void SubRoom::SetSubRoomID(int ID)
 {
@@ -127,7 +126,7 @@ int SubRoom::GetRoomID() const
 
 int SubRoom::GetNumberOfWalls() const
 {
-     return _walls.size();
+     return (int)_walls.size();
 }
 
 const vector<Wall>& SubRoom::GetAllWalls() const
@@ -157,7 +156,7 @@ const vector<Obstacle*>& SubRoom::GetAllObstacles() const
 
 int SubRoom::GetNumberOfGoalIDs() const
 {
-     return _goalIDs.size();
+     return (int)_goalIDs.size();
 }
 
 const vector<int>& SubRoom::GetAllGoalIDs() const
@@ -166,8 +165,6 @@ const vector<int>& SubRoom::GetAllGoalIDs() const
 }
 
 
-// Sonstiges
-
 void SubRoom::AddWall(const Wall& w)
 {
      _walls.push_back(w);
@@ -202,7 +199,7 @@ void SubRoom::AddHline(Hline* line)
 {
     for(unsigned int i=0;i<_hlines.size();i++){
         if (line->GetID()==_hlines[i]->GetID()){
-            Log->Write("INFO:\tskipping duplicate hline [%d] in subroom [%d]",_id,line->GetID());
+            Log->Write("INFO:\tskipping duplicate hline [%d] with id [%d]",_id,line->GetID());
             return;
         }
     }
@@ -305,8 +302,78 @@ Point SubRoom::GetCentroid() const
      return Point(px,py);
 }
 
+std::vector<Wall> SubRoom::GetVisibleWalls(const Point & position){
+#define DEBUG 0
+     std::vector<Wall> visible_walls;
+     bool wall_is_vis;
+     Point nearest_point;
+#if DEBUG
+     printf("\n---------------------------\nEnter GetVisiblewalls\n");
+#endif
+     for (auto w:_walls){
+          // nearest_point = w.ShortestPoint(position);
+          wall_is_vis = IsVisible(w, position);
+          if(wall_is_vis){
+#if DEBUG
+               printf("  GetVisibleWalls: Wall (%f, %f)--(%f, %f)\n",w.GetPoint1().GetX(), w.GetPoint1().GetY(),w.GetPoint2().GetX(), w.GetPoint2().GetY() );
+               printf("  GetVisibleWalls: Ped position (%f, %f)\n",position.GetX(), position.GetY());
+               printf("  GetVisibleWalls: wall is visible? = %d\n",wall_is_vis);
+#endif
+               visible_walls.push_back(w);
+          }
+     }
+#if DEBUG
+     printf("Leave GetVisiblewalls with %d visible walls\n------------------------------\n",visible_walls.size());
+ #endif
+     return visible_walls;
+}
+
+// like ped_is_visible() but here we can exclude checking intersection
+// with the same wall. This function should check if <position> can see the <Wall>
+bool SubRoom::IsVisible(const Line &wall, const Point &position)
+{
+     // printf("\tEnter wall_is_visible\n");
+     // printf(" \t  Wall (%f, %f)--(%f, %f)\n",wall.GetPoint1().GetX(), wall.GetPoint1().GetY(),wall.GetPoint2().GetX(), wall.GetPoint2().GetY() );
+
+     bool wall_is_vis = true;
+     // Point nearest_point =  wall.ShortestPoint(position);
+     // in cases where nearest_point is endPoint of Wall, the wall becomes visible even if it is not..
+     //  try with the center. If it is not visible then the wall is definitly not.
+     Point nearest_point =  wall.GetCentre();
+     // printf("\t\t center of wall %f, %f\n",nearest_point.GetX(), nearest_point.GetY());
+     Line ped_wall = Line(position, nearest_point);
+     for (auto w:_walls){
+          if(w == wall) //ignore wall
+               continue;
+          if(wall_is_vis  && ped_wall.IntersectionWith(w)){
+               // fprintf (stdout, "\t\t Wall_is_visible: INTERSECTION WALL  L1_P1(%.2f, %.2f), L1_P2(%.2f, %.2f), WALL(%.2f, %.2f)---(%.2f, %.2f)\n", ped_wall.GetPoint1().GetX(),ped_wall.GetPoint1().GetY(), ped_wall.GetPoint2().GetX(), ped_wall.GetPoint2().GetY(), w.GetPoint1().GetX(),w.GetPoint1().GetY(),w.GetPoint2().GetX(),w.GetPoint2().GetY());
+               wall_is_vis = false;
+          }
+     }
+
+     //check intersection with obstacles
+     for(unsigned int i = 0; i < _obstacles.size(); i++) {
+          Obstacle * obs = _obstacles[i];
+          for(unsigned int k = 0; k<obs->GetAllWalls().size(); k++) {
+               const Wall& w = obs->GetAllWalls()[k];
+               if(wall_is_vis && ped_wall.IntersectionWith(w)){
+                    // fprintf (stdout, "\t\t Wall_is_visible INTERSECTION OBS; L1_P1(%.2f, %.2f), L1_P2(%.2f, %.2f), L2_P1(%.2f, %.2f) L2_P2(%.2f, %.2f)\n", w.GetPoint1().GetX(), w.GetPoint1().GetY(), w.GetPoint2().GetX(), w.GetPoint2().GetY(), ped_wall.GetPoint1().GetX(), ped_wall.GetPoint1().GetY(), ped_wall.GetPoint2().GetX(), ped_wall.GetPoint2().GetY());
+                    wall_is_vis = false;
+                    
+               }
+          }
+     }
+
+     // printf("\tLeave wall_is_visible with %d\n", wall_is_vis);
+     return wall_is_vis;
+}
+
+// p1 and p2 are supposed to be pedestrian's positions. This function does not work properly 
+// for visibility checks with walls, since the line connecting the pedestrian's position 
+// with the nearest point on the wall IS intersecting with the wall.
 bool SubRoom::IsVisible(const Point& p1, const Point& p2, bool considerHlines)
 {
+     // printf("\t\tEnter ped_is_visible\n");
      // generate certain connection lines
      // connecting p1 with p2
      Line cl = Line(p1,p2);
@@ -316,12 +383,12 @@ bool SubRoom::IsVisible(const Point& p1, const Point& p2, bool considerHlines)
      for(unsigned int i = 0; i < _walls.size(); i++) {
           if(temp  && cl.IntersectionWith(_walls[i])){
                L2 = _walls[i];
-               // fprintf (stdout, "INTERSECTION WALL  L1_P1(%.2f, %.2f), L1_P2(%.2f, %.2f), L2_P1(%.2f, %.2f) L2_P2(%.2f, %.2f)\n", L1.GetPoint1().GetX(),L1.GetPoint1().GetY(),L1.GetPoint2().GetX(),L1.GetPoint2().GetY(), L2.GetPoint1().GetX(),L2.GetPoint1().GetY(),L2.GetPoint2().GetX(),L2.GetPoint2().GetY());
+               // fprintf (stdout, "\t\t INTERSECTION WALL  L1_P1(%.2f, %.2f), L1_P2(%.2f, %.2f), L2_P1(%.2f, %.2f) L2_P2(%.2f, %.2f)\n", L1.GetPoint1().GetX(),L1.GetPoint1().GetY(),L1.GetPoint2().GetX(),L1.GetPoint2().GetY(), L2.GetPoint1().GetX(),L2.GetPoint1().GetY(),L2.GetPoint2().GetX(),L2.GetPoint2().GetY());
                temp = false;
           }
      }
 
-
+     // printf("\t\t -- ped_is_visible; check obstacles\n");
      //check intersection with obstacles
      for(unsigned int i = 0; i < _obstacles.size(); i++) {
           Obstacle * obs = _obstacles[i];
@@ -329,7 +396,7 @@ bool SubRoom::IsVisible(const Point& p1, const Point& p2, bool considerHlines)
                const Wall& w = obs->GetAllWalls()[k];
                if(temp && cl.IntersectionWith(w)){
                     L2 = w;
-                    // fprintf (stdout, "INTERSECTION OBS; L1_P1(%.2f, %.2f), L1_P2(%.2f, %.2f), L2_P1(%.2f, %.2f) L2_P2(%.2f, %.2f)\n", L1.GetPoint1().GetX(),L1.GetPoint1().GetY(),L1.GetPoint2().GetX(),L1.GetPoint2().GetY(), L2.GetPoint1().GetX(),L2.GetPoint1().GetY(),L2.GetPoint2().GetX(),L2.GetPoint2().GetY());
+                    // fprintf (stdout, "\t\t INTERSECTION OBS; L1_P1(%.2f, %.2f), L1_P2(%.2f, %.2f), L2_P1(%.2f, %.2f) L2_P2(%.2f, %.2f)\n", L1.GetPoint1().GetX(),L1.GetPoint1().GetY(),L1.GetPoint2().GetX(),L1.GetPoint2().GetY(), L2.GetPoint1().GetX(),L2.GetPoint1().GetY(),L2.GetPoint2().GetX(),L2.GetPoint2().GetY());
                     temp = false;
                     
                }
@@ -345,6 +412,7 @@ bool SubRoom::IsVisible(const Point& p1, const Point& p2, bool considerHlines)
                     temp = false;
           }
 
+     // printf("\t\tLeave ped_is_visible with %d\n",temp);
      return temp;
 }
 
@@ -393,9 +461,6 @@ bool SubRoom::IsVisible(Line* l1, Line* l2, bool considerHlines)
      return temp[0] || temp[1] || temp[2] || temp[3] || temp[4];
 }
 
-
-
-
 // this is the case if they share a transition or crossing
 bool SubRoom::IsDirectlyConnectedWith(const SubRoom* sub) const
 {
@@ -488,7 +553,7 @@ bool SubRoom::SanityCheck()
 ///http://stackoverflow.com/questions/471962/how-do-determine-if-a-polygon-is-complex-convex-nonconvex
 bool SubRoom::IsConvex()
 {
-     unsigned int hsize=_poly.size();
+     unsigned int hsize=(unsigned int)_poly.size();
      unsigned int pos=0;
      unsigned int neg=0;
 
@@ -700,7 +765,7 @@ bool NormalSubRoom::IsInSubRoom(const Point& ped) const
 
      /////////////////////////////////////////////////////////////
      edge = first = 0;
-     quad = WhichQuad(_poly[edge], ped);
+     quad = (short) WhichQuad(_poly[edge], ped);
      total = 0; // COUNT OF ABSOLUTE SECTORS CROSSED
      /* LOOP THROUGH THE VERTICES IN A SECTOR */
      do {
@@ -725,6 +790,7 @@ bool NormalSubRoom::IsInSubRoom(const Point& ped) const
           case -3: // MOVING BACK 3 IS LIKE MOVING FORWARD 1
                delta = 1;
                break;
+               default:break;
           }
           /* ADD IN THE DELTA */
           total += delta;
@@ -938,9 +1004,9 @@ bool Stair::ConvertLineToPoly(vector<Line*> goals)
      // ganz kleine Treppen (nur eine Stufe) nicht
      if ((neuPoly[0] - neuPoly[1]).Norm() > 0.9 && (neuPoly[1] - neuPoly[2]).Norm() > 0.9) {
           for (int i1 = 0; i1 < (int) orgPoly.size(); i1++) {
-               int i2 = (i1 + 1) % orgPoly.size();
-               int i3 = (i2 + 1) % orgPoly.size();
-               int i4 = (i3 + 1) % orgPoly.size();
+               unsigned long i2 = (i1 + 1) % orgPoly.size();
+               unsigned long i3 = (i2 + 1) % orgPoly.size();
+               unsigned long i4 = (i3 + 1) % orgPoly.size();
                Point p1 = neuPoly[i1];
                Point p2 = neuPoly[i2];
                Point p3 = neuPoly[i3];
diff --git a/src/geometry/SubRoom.h b/src/geometry/SubRoom.h
index 72e640e070e4f0e570d90863192ec659a27acdb4..01b2f5c7b10f7c09df0541f352cb9c49d8fc4cb9 100644
--- a/src/geometry/SubRoom.h
+++ b/src/geometry/SubRoom.h
@@ -1,7 +1,7 @@
 /**
  * \file        SubRoom.h
  * \date        Oct 8, 2010
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -123,6 +123,11 @@ public:
       */
      const std::vector<Wall>& GetAllWalls() const;
 
+     /**
+      * @return visible walls from position of pedestrians (considering the direction of motion)
+      */
+     std::vector<Wall> GetVisibleWalls(const Point & position);
+
      /**
       * @return a reference to the wall at position index
       */
@@ -273,7 +278,7 @@ public:
      /**
       * @return true if the two segments are visible from each other.
       * Alls walls and transitions and crossings are used in this check.
-      * The use of hlines is optional, because they are not real, can can be considered transparent
+      * The use of hlines is optional, because they are not real and can be considered transparent
       */
      bool IsVisible(Line* l1, Line* l2, bool considerHlines=false);
 
@@ -284,6 +289,12 @@ public:
       */
      bool IsVisible(const Point& p1, const Point& p2, bool considerHlines=false);
 
+     /**
+      * @return true if the two points are visible from each other.
+      * Alls walls and transitions and crossings are used in this check.
+      * The use of hlines is optional, because they are not real, can be considered transparent
+      */
+     bool IsVisible(const Line &wall, const Point &p2);
 
      // virtual functions
      virtual std::string WriteSubRoom() const = 0;
diff --git a/src/geometry/Transition.cpp b/src/geometry/Transition.cpp
index f27e39ed9bcf0060d4370806ac73518b1359dd8c..1d285afeee5e385238e5ade2cabddd522f442a79 100644
--- a/src/geometry/Transition.cpp
+++ b/src/geometry/Transition.cpp
@@ -1,7 +1,7 @@
 /**
  * \file        Transition.cpp
  * \date        Nov 16, 2010
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -178,7 +178,7 @@ void Transition::WriteToErrorLog() const
 }
 
 // TraVisTo Ausgabe
-string Transition::WriteElement() const
+string Transition::GetDescription() const
 {
      string geometry;
      char tmp[CLENGTH] = "";
diff --git a/src/geometry/Transition.h b/src/geometry/Transition.h
index 0ee3e76c50713bb244dd668cc6699d57a603a3a3..a19854540e69e1743b7b762f45a93e48f7889c16 100644
--- a/src/geometry/Transition.h
+++ b/src/geometry/Transition.h
@@ -1,7 +1,7 @@
 /**
  * \file        Transition.h
  * \date        Nov 16, 2010
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
@@ -113,7 +113,7 @@ public:
 
 
      virtual void WriteToErrorLog() const;
-     virtual std::string WriteElement() const; // TraVisTo Ausgabe
+     virtual std::string GetDescription() const; // TraVisTo Ausgabe
 };
 
 #endif  /* _TRANSITION_H */
diff --git a/src/geometry/Wall.cpp b/src/geometry/Wall.cpp
index b4a85122503ec8c5683bdbe8c642730613ea20f5..fa5ba4dd8b3f151af5cedf8bcce0421ccf3a1f67 100644
--- a/src/geometry/Wall.cpp
+++ b/src/geometry/Wall.cpp
@@ -1,7 +1,7 @@
 /**
  * \file        Wall.cpp
  * \date        Nov 16, 2010
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License
diff --git a/src/geometry/Wall.h b/src/geometry/Wall.h
index 42829e20711ff9b0c0e866a0f89b3c5fc21d5305..6babac37e0b971c037748e87e688352a2fc517f7 100644
--- a/src/geometry/Wall.h
+++ b/src/geometry/Wall.h
@@ -1,7 +1,7 @@
 /**
  * \file        Wall.h
  * \date        Nov 16, 2010
- * \version     v0.5
+ * \version     v0.6
  * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
  *
  * \section License