Added safety checks.