Fixes polling and `new` bug, refactors for better memory usage, upgrades URL parsing

Callbacks scheduled via setInterval won't be executed in the correct
context unless bound to `this` with `Function.bind()`. Also updated the code for JS best practice, and fixed some low-hanging bugs that affected the test/sample documents.