Fix various merge conflicts and PR the latest improvements