Add deferred writes to localstorage

Allow the author to perform multiple writes to the DB without flushing to localstorage after each write. While unsafe in that the data may not be stored, allows for better performance. Calls to switch to deferred mode may be nested.