Replace GatherTransforms with a visitor
Merge pull request #2686 from Luomu/misc-cleanup

Much nicer way of doing it! Merging.