Change history functionality

Now properly encodes special characters for the history URL.