More JS refactor and fix URL

URL now only has the junk in it if you use the permalink button.  All old links should still work.