Fixed PHP 5.5 patch, still needs reworking to fix TODO items