Updated to use the new database. With tests.