Added some logic.
Removed all the callback crap from the backend.
Added tests.