Improve/fix some regexes; quote newlines correctly