Cleaned up some code and added graph connectivity test