Cleanup code in errorhandling of daemon.py