Added logic to allow for in-memory and permanent databases
added dbInMemory option