Refactor daemonizing code for style problems