Database stuff mostly

Mostly database work.  Other minor fixes