Fix unpredictable iteration order