Revert "No more aborting on exception for the daemon, and tidied up som error handling"

This reverts commit 5cb5a517a185de43d7b19024614ecac2de95d574.
Revert "Fix query bug"

This reverts commit d8e29d096b652d83a055ae97a21bae005df5755d.