Add support for running a daemon

Also adds support for changing directories