Reorganize variables and functions

Move functions around, merge the getTopToBottomData function into getFileStats, and create an openFile function to simplify the bufferUse/groups functions.