Fixed some problems in PHP 5.2