logging fixes and database stuff