Should fix issue #63 (HTML entities rendered incorrectly), and refractor code a bit.