Clean up putch and implement kbhit.