Optimize the _RE_HR regexp to avoid catastrophic backtracking. Also update the _RE_CODE regexp to allow leading space and the _RE_HEADER regexp to require a space-character after the leading `#`. The latter avoids matching long sequences of `#` which could also potentially lead to catastrophic backtracking.