Improve weird code to more clearly
Remove unnecessary comments
Improve circular waiting detecting. close #465