Backport last fixes