I totally agree, and I would just **love** to have a mapserver/mapscript both thread safe and performant.

By coincidence (or not, if you believe in fate) a possibile cause was brought up on the ml today:

http://lists.osgeo.org/pipermail/mapserver-dev/2013-August/013509.html

assuming that epsgCode var is the culprit it's a lot of effort to clean it up.
I would gladly do it if I had the time, but I am running very short of it at the moment ;-)