Added Joe's modifications
Changed list function to work on windows without dirent.h