deal with nans; not sure if this is correct. also initialize the matrices for posttests in the right place.