Documentation

Comments updated to improve doc layout; some minor refactoring between
main and dbadapter to put db specific functionality in db module and cli
specific functionality in main