applies ac6443c76433bd12926f
uses Array#slice as in upstream