Refactors main.js to make it clear which paths the app responds to and easier to spot specificity errors.