Rewrote command runnung as a separate thread.