Add some safety checks.