More fixes that have to do with the memory optimisations. Also fixed a bug in the mark6 optimal statistic.