Moved disambiguation into the transformation itself, to make it work when called from java/scala
Merged by taking jeffs changes