Fix ArrayList.replaceX methods, other small fixes

* `ArrayList.replace` was missing `i++` ⇒ infinite loop
* `ArrayList.replaceFirst` and `replaceLast` were using `set(index, element)` instead of `set(index, replacement)`