Partial rewrite, specs included.