Fixing various PHP errors