Code clean-up (global pointers, $e107->, headers). Got rid of all $e107->this->sql and tp