first cut

fixed version

some cleanups
more cleanups
fix some tests