Move language code to "lang" query parameter

Uses HTML5 `history.pushState` with fallback to `window.location`

Also fixes/refactors some code here and there.

Closes gh-108