Fix some sneaky bugs in the UI interface code and input handling