Rewrite for fun and profit (and understanding)