Fixing bunch of PHP notices and warnings