Rewrite: use underscore.js implementation

Thoughts? This version is a lot more robust. We'll need to tag as v1.0.0 after merge and publish on npm accordingly.