Switched to scoped_arrays to avoid memory leaks.