Improved error checking in _validate_inputs.