Refactor router and add listeners to views