Add some more error checks.