Fix various regressions and warnings