The crash in "explain" looks very like this bug:
But that bug is fixed in You claim to be running, but I don't think you can be.
By the way... I don't understand the meaning of the "OPT" messages, what is it complaining about?
It's not complaining about anything. When you use -explain, you switch on two options: (a) optimizer tracing, which tells you where the expressions have been rewritten by the optimizer for efficiency, and (b) a display of the final expression tree after all the rewrites have been completed. For example, it's telling you that ss:Cell[$start-col] was replaced with the internal function call itemAt(ss:Cell, 5).  This doesn't mean that there is anything wrong with your code; on the contrary, it's good if you write your code in a way that can be optimized. In this case the optimization allows Saxon to directly select the 5th item in the input sequence, rather than scanning the whole input sequence and testing each item to see if its position number is 5.
Michael Kay