Simplified the program a bit with fewer parameters passed and more local
variables. Eliminated a function or two as well as the commented out
debugging code. It still works.