Fix issues with dir_read implementation