Fix custom matrix bug, some references were mismatched