Fixed compatiblity issues with PHP 5.2