Introduced the connectivity parameter, regrouped some code