fixed some bugs with PHP 5.3