more work on rewrite, base functionality significantly complete