Fixed bugs in input error handling