Cleaned up DB access code. Working well. Next commit will remove old code.