Fixed memory corruption
Don't block on stdin
Handle functional keys correct, quit on EOT