restructured and simplified CGI.

NB: I'm struggling to test the CGI - something is wrong I think.. I
can't work out how the original outputtedthe final written bibtex file