Cleanup code and standardize callbacks.