Cleanup of some of the code.  Getting ready to publish into Moodle Plugins.