further clean command handler

Done cleaning up the command handler. Moved commandhandler stop code around.