Possible fix for broken toArray method at runtime