With a couple changes, works fairly well as daemon.