Improved setlocale(). Eliminated locale comparison in ext/pcre if it's not necessary.
Avoid NULL pointer dereferencing