Added database support and some tests.