Improved directory handling.