Better handling of HTML codes
Changes for better python 3 compatibility