Fixed some errors + PHP 5.5+ workaround