Save state, rewrite database promises to support SQLite