Various fixes to the CGI engine.
Enhanced debugging output.