refactor daemon code, moved commands to core/commands