Improved ambiguity avoidance strategy.
Added test.