started adding stats computation

also beginning to factor out "internal" functions that should not be
exposed, and began unit testing