optimizing matrix stuffing
all unit tests pass