Implement automatic directory removal handling