Improve logging and make errors go to the log
Use log instead of stderr, since we're daemonized
Move forward declaration of thread routine to the right place
Don't return until we're done initialising.

Sometimes, I question my own intelligence.