Handle invalid input without crashing. Closes #82.