More cleanup, simplification and optimization.