Fixed PHP warnings; code cleanup