prevent duplicate instances; proper exit codes; clean up all daemons on shut down; refactoring