Added hanging subgraph check. Imporved cycle detection. Hanging check needs more testing