Add connectivity support
Improve performance by preallocating memory