optimize generation counters and add Directory object mutex