@Periko,
I have not made any code modifications to get this to work. I noticed this was happening on my server with CentOS 5 and PHP 5.3.

I ended up reinstalling Cent and re-compiling PHP and this cleared up the strange errors I was getting. I did not change any code.

I'm still not sure what the root cause of this was. I racked my brain for a couple of days trying to figure this one out because there is not really a workaround that I know of if you have this issue. The only thing that worked for me was reinstalling everything on the server, and that cleared it up.