Rewrite daemon as thread, use inverse logic