Fix potential null ref exception.