Added toArray method on generated objects