Rebased to the latest upstream changes