Refactoring. Still a bit needed yet but it's making abstracting 3rd party ORMs easier.

Signed-off-by: Ben Corlett <bencorlett@me.com>