Some transform refactoring and gradient hacks.