Prep daemon code for threading