Added stricter parameter checking, returning false when invalid.