Added count to EventStore
Close db on dealloc
Call flushBuffer if db is not empty