rebased to latest upstream