Img Optim: Refactorings and tweaks