Fixed memory leak on gradient