Cleanup sloppy database implementation and begin usage