Adding more defensive checks.