Add replace null check for infinite loop
Refactor conditionals in TransformConnector#transform for clarity