Clean up input values before turning them into integers

One of the tasks in this story https://www.pivotaltracker.com/story/show/51963243