Better keyboard interrupt handling. Move worker running code into separate function.