Added XSS protections and improved the doctests.