now using the expected intermediate directory name
use error names instead of codes
better handle concurrency in purge()
allow partial purging