Fixed Logging and Database Issues