Fixed some PHP code warnings and minor bugs