Refactored some input code.