refactor to split the analysis out of classes.r and minimise the number of runs over it.

(this is totally unstable: mostly exists for easy remote testing)