Bug fixing the daemon to cleanup properly
refactor
Basic working daemon