More refactoring

- reverting back index.js(need to figure our better way to do this)
- refactoring/cleanup library.js and validate.js