Simplified purging mechanism, which is now based on desired free space only; minor cleanup changes