Export of database to new adjacency list format

Making a pull request since the commit is so large.