Added some validation checks.