Correctly handle empty arrays.