Fix gradient calculations