Refactored auto-focus to use only one register function which takes in two callbacks. Fixed pressing ESC in editor, it seems  is unavoidable there.