Refactored codebase into multiple, specific functions.