Update main.js

Reorganized hierarchy, added form objects for validation.