Formatting cleanup and rewrite to remove the callback dependencies.
Cursor tests are passing.