Fix compilation warnings
Add connectivity check functions
Minor optimization