Database stuff. Initial implementation. Does not work yet.