Fixed some errors and PHP 5.5+ workaround