daemon code cleanup