Fixing hist to avoid Inf values, correct derivatives now in egp3