         sqlite3_commit_hook(database.sqliteConnection, { brokerPointer in
             let broker = Unmanaged<DatabaseObservationBroker>.fromOpaque(brokerPointer!).takeUnretainedValue()
             do {
-                try broker.willCommit()
-                broker.transactionHookState = .commit
+                try broker.databaseWillCommit()
+                broker.transactionState = .commit
                 // Next step: updateStatementDidExecute()
                 return 0
             } catch {
-                broker.transactionHookState = .cancelledCommit(error)
+                broker.transactionState = .cancelledCommit(error)
                 // Next step: sqlite3_rollback_hook callback
                 return 1
             }

        
        sqlite3_rollback_hook(database.sqliteConnection, { brokerPointer in
            let broker = Unmanaged<DatabaseObservationBroker>.fromOpaque(brokerPointer!).takeUnretainedValue()
            switch broker.transactionHookState {
            case .cancelledCommit:
                // Next step: updateStatementDidFail()
                break
            default:
                broker.transactionHookState = .rollback
                // Next step: updateStatementDidExecute()
            }
        }, brokerPointer)

        }
    }
    
    // Called from sqlite3_commit_hook
    private func databaseWillCommit() throws {
        // Time to send all buffered events
        
        let eventsBuffer = savepointStack.eventsBuffer
        savepointStack.clear()
        
        for (event, observations) in eventsBuffer {
            for observation in observations {
                event.send(to: observation)
            }
        }
        
        for observation in transactionObservations {
            try observation.databaseWillCommit()
        }
    }
    
    // Called from updateStatementDidExecute
    private func databaseDidCommit() {
        savepointStack.clear()
        
        for observation in transactionObservations {
