Improve error checks.