Refactoring daemon_control