Make common changes for collect sets code improvement