Implemented multple directory detection and handling.