Clean up error logging and handling