Fix errors with empty arrays