updating daemon control code to be in a separate file

The code that controls and watches the daemon is now in its own file. I've also updated the
extension and prefs file to reflect the new code. With the code separated, it will be easier
to manage and update in the future.