Revert over-aggressive optimization, and various cleanup.