re-factored code to make it more like a module rather than have global variables all over the place.  Now I need to add tests for the new get_* methods