restructure code a bit to make more modular, add missing deps, add npm s...

i commented a bunch inline
basically when its a prototype (e.g. uses `new`) you use CapitalCase but anything else is camelCase