I refactored some code and added more comments.
I now have everything working. I will run tests, capture output and package everything up to turn into Caterpillar.