Various refactoring in searching for good conditions.