fixed #776 for good (i.e. for PHP 5.2.6 and higher)