Stabilized main code.