adding optional logging, more tests, fixing bugs.  Also added functionality to rebuild function for @bkreider.  This fixes #23.