refactored init.js

A bunch of optimizations:

-removed erroneous / unnecessary variable declarations
-DRYed up some repeated functions
-added constants (e.g. SMALL, LARGE)
-switch to vanilla Javascript for computationally-intensive functions
-general code cleanup for readability