Added in a check to not load hidden files/folders
And added a new function to tidy up code that ended up being identical.