Better handling of Esc (should work in all cases now) and keys
Cleanup (style/workarounds), update comments/docstrings