updated: aligned with latest upstream.