Add some more checking -- don't want non-gc values to sneak in again
Fix memory leak of RewriterVars when the rewrite doesn't commit

I'm not sure I like the current approach, but it seems to be working.
Proper memory freeing behavior, courtesy of Travis