Improve and document the databases layer