Merged change from readdir_r() to readdir() + threading