Preliminary database inserts. Needs lots of tests.