Added checks against negative coordinates in isValid().