Fixes + rough validation.
Organised main.js and comments added