Try to get the daemon mode to work

Also try to make the parent process kill the child processes.
Try to fix daemon mode.

Didn't succeed in fixing it, but cleaned up code. Need to understand
why daemon gets new pid, and why.
* How to kill child processes?
* How to use pid files (and lock files) properly
* How to use signals properly?