Merge thenHandlers processing logic into doSettle.
Convert function expressions to named functions for better debugger appearance.
Remove state variables entirely as they are only used in one place.