Remove toArrayOfKeys and do less slicing