Added precondition checks.