Updated and cleaned up code also fixed text input

Bugs: You need to press enter twice after entering text!