Improve database error logging
Clean up message registration