Some more code clean-up (global pointers, $this->e107->, $sql)