Fixed a number of issues

Fixed wrong parsing of broken records; HTML entities; encoding, and some
others.