Move coercion optimization to leafs, fixing some bugs