Rebased to latest upstream