remove unused images and optimize the rest