Fixing Portfolio Gradient Issues