scrub invalid db entries on startup and other misc cleanups