fix some bugs in coalesce