Reset state on refocus (fixes some stuck keys)
some work towards py3 compat + name the process