Added additional directory cleanup functionality

This is an attempt to resolve #186. It makes sure that empty
directories get pruned along with the items inside of them during a
cache clear. If an item is the last one to be removed from a directory
this will run some tests and then clean that directory up.
Merge pull request #196 from tedious/rmdir

Added additional directory cleanup functionality