Use `replace` to avoid losing punctuation.
Clean up missing semicolons. Simplify scope.