Attempt to fix random disconnects
Removed trailing whitespace
Add daemonizing code