Fixed Alans checkgrad bug