Implemented userInput event and fixed some bugs.