Bugfixes

This fixes 2 bugs.  One an unreported bug where a variable could be undefined. 

The second is bug 2989, where timing out would cause the text in PG editor to be html encoded.  

(This was caused by overzealous encoding in ContentGenerator.  CGI already auto encodes html emitted by form generating functions, so removing the encoding doesn't expose anything.)