Move all the input handling in its own module