Refactored main.js into views.js.