Refactored the code to allow for a central repository of helper functions and combined helper functions.