Add image optimization and clean up the rest of the code for the imageOptimizer.