Initial commit of code rewrite.  Needs more documentation and demo page.