Continued refactoring and rewriting of functions to reflect new data structure