Database initialization with no bugs.

TODO: make serialization/deserialization of sets.