Fix issues with PHP 5.2 compatibility