BTreeMap: fix ArrayIndexOutOfBoundsException in `replace` and `put` methods. See #304