Bug fix for PHP errors