Database creation and memory management stuff