Refactored main.js file. Finished with main infrastucture.