Corrected a bug in the unloading fit routine causing a crash in the optimization procedure in some cases.