Fix segfault on mac

It seems that when not keeping a ref to the thread starting the
io_service may case a segfault when calling ~thread. In order to prevent
this the thread is joined when stopping the server.
Added directories preprocessed header
Using cout for all log messages (waiting for a good log library)