Code clean-up (globals, $e107->, headers, $sql)