Document, reorganize main.js