Adds input handilng. Fixes few bugs with parser.