More refactoring around input validation.