bugs - mostly undeclared vars and lack of isset