Obey naming conventions.
Clean up exception handling.
Don't attempt to process packet on I/O error.
Fix key press handling code style.
Exit on <Ctrl>-Q or <Ctrl>-W.
Move one-shot states out of main client loop.
Fix error handling in main client loop.
Style fixes.
Fix error handling.