PHP errors. Restructuring