refactor chat window input code, misc fixes