Changed dbs to use sets and dicts