Remove dirent sorting, and fix some code style