Fix some bugs of invalid input.