Fix optimal_freq logic on ramp down (Thanks to Faux123)