Aggregate state code working to first order.
Code now working, ready for cluster run