Add more input validation

Didn't this get created in a separate pull request? Regardless, I've seen this already.