Fix segfault when in TRAINED mode.