refactor chat window input code, misc fixes
Merge pull request #5 from Tox/master

Sync with main project