Remove buggy ESC mapping and refactor a lot