tightened up function signatures
added some diagnostic code.  added timing.