HTML escaping and general fixes