Refactoring

Added logger and introduced loop method in controller daemon.