DavidBurns changing algorithm to handle the transforms. Fixes issue 5010