Python 3 support and better KeyboardInterrupt handling