CLeanup and comments.
Merge branch `rewrite` into `master`.