optimize images and remove unused ones