Also added a fix in this line. It could happen that `$aPositions` is empty at this point, which will give an error from `min()`.