Debug output controlled by SIGUSR1

There is a KM_DBG variable that enables/disables extensive debug output.
It can be enabled by sending SIGUSR1.