add a few failsafe checks.