Reorganized daemon code.