Patch for issue #119

I hope this is sufficient to fix #119, and it didn't introduce any new vulnerability. I feel that this is a must for live deployments to avoid service interruption in the future when PHP 5.5 comes out.