changes to make ApplyMappingMatrix to work