datastore: refactor transaction & datastore.

Hello again!

I rearranged a few things, hopefully for the better. I'll leave comments. :)
Easier to say `var Query = require('./query');` than `var Query = require('./query').Query`.