The existing frequency control framework in power systems is challenged by lower inertia and more volatile power injections. We propose a new framework for frequency control and congestion management. We formulate an optimization problem that rebalances power, restores the nominal frequency, restores inter-area flows and maintains line flows below their limits in a way that minimizes the control cost. The cost can be squared deviations from the reference generations, minimizing the disruption from the last optimal dispatch. Our control thus maintains system security without interfering with the market operation. By deriving a primal-dual algorithm to solve this optimization, we design a completely decentralized primary frequency control wit...