Make JS-SDK work from Node.js

Yeah, they're logically equivalent but they're easier to understand and callback && callback(null, result) as an expression without use makes JSHint angry. I tried to break up a few of the more complex bits and fix most of the JSHint errors where I could.