Cleaned and almost totally functional. I just want to try out the module pattern, and then I'll check it in and move on.
more cleaning and modularization. I have one more step, and then I'll have three high-level modules and this code will be ready to build on.