Commit before switch optimization
Preliminary optimization.
Optimization round 1
Optimization round 2
Optimization round 3