Fixed typo with indexes in getGradient(x/y) functions.