Made it working for current PHP version.