Cleanups

Adds a bunch of cleanups and test for the callbacks.