fix several notices and a few bugs caused by variable name/ non-declaration issues (all caught by ZDE's analyze feature, incidentally)
fix several notices and a few bugs caused by variable name/
non-declaration issues
(all caught by ZDE's analyze feature, incidentally)


marcosptf/pear-core,marcosptf/pear-core,marcosptf/pear-core,marcosptf/pear-core,marcosptf/pear-core,marcosptf/pear-core