Bug fixes and improvements to the db auth check.