Small fixes to reduce calls to ismember and unique in simple cases