Rewrite History/Router
Refactor to keep jshint happy