Rewrote threading to respect KeyboardInterrupt