Rework #transform logic. Needs testing.