Fixed issue with custom gradients