Adjusted code to account for changes in PHP 5.5.