Fixes all kinds of stuff

Initially I was just going to fix this so the tests could run on node but then I found a bunch of other bugs and things in the documentation. Check out what I did and merge it if you want to. I've been using it in this state for awhile now and it's doing what I want it to.