Switched from pairs to optionals. Moved database models to separate file.