Refactor to favour deferred over callback.

Trying to avoid callback hell with a simple deferred object.
May switch this to a promise/A+ implementation at some point, for now
error handling is very very basic.