Changed the way invalid inputs are handled.