Improve error/validation handling