factor out dirlib