Updates to Carls' PR for contributor report

Created to display how I would modularize this code to make it more readable. Examples of smaller well-named functions with no side effects, with single responsibilities.

Feel free to ignore this and just use it as a lesson, or merge into your PR.