Fixed some php errors relating to undeclared variables, etc.
Fixed more undeclared variable bugs