Fixed recently broken gradient code

It turned out that "repeat" was already a property of String.
I renamed some variables and did minor cleanup.