minor changes ported from another repo with reverse engineered copy from Ribbon