File tree building cleanup

Does a light cleanup to the functions involved in building the file tree for the file viewer.