Fixed some logging and DB issues