Formatting cleanup, and fix regex escaping bug