Moved input code from event thread. Fixes #2