Implement directory removal and free space detection

This implements #1 and #3. I used #1 in production so far.