tidy up, analysis code rework