Fixed issue with encoding HTML characters. I am not too happy with the end result but it works. Should revisit later on