Changes to keep the stdp learning between runs, moved distance calc as it is only needed on first run, and added logging for optimisation