Code now appears to properly handle transformations, but is SLOW