Ignore missing = at end of encoded string while decoding
Switched to using history.replaceState and the query part of the URL instead of the hash
Fixed hash links to headers from TOC