Fixed SegFault after opendir