Fixing some issues with logging and errors