Fix a few bugs, as well as a memory leak.
Fix installation directory for the daemon.