Clean up + xss fixes

As requested in issue #40.