Started working on hysteresis. Not working yet, but getting closer.