implement aggregation for multiple samples per individual; fix some bugs