Escaping and error handling.

Escaping for html pastes, some error handling.