Cleanup code and standardize callback.