Fixed two bugs with PHP 5.2