changed matrix to matrix4x4 where appropriate