Added option to set a maximum cost for the cache. Added method to clear images from memory