Refactor getFileList and add some tweaks