Rework core logic

Completely rework the core logic to be much less fragile
 * extracted core logic
 * use a set of channels which we switch on/off in the CoreLoop
 * handle signals
 * kill process groups
 * heavy commenting on unix and Go specific stuff
 * more test coverage + cleanups + more logging of strange cases.

On top of these changes, soft kills, command retries and kill retries are quite easy to realize as this just needs to add channels or modify the set of active channels.

@mlafeldt PTAL