Added glance cache cleaning and pruning

This is a rebase of #521.