Add config rewriter. Other minor fixes.