Refactored and tested optimizations in a row