Mostly Working Daemonization. Refactoring.