I found 2 problems:
1 - your change to "replace" the Mid$ function (I created a similar function and now this part does not crash);
2 - I have yet to find out why but there are problems using a Long as a Map key.
In this part of your source:
XYS.Put(i + j - 1, XYS.Get(i + j - 1) + x.Get(i) * y.Get(i))
the Map x contains: 1 (key) 1 (value).
x.Get(i) results Null only because "i" is declared as Long; if you declare it as Int, 1 is returned as expected.
Still studying
In the meantime I am attaching the B4XPages version so you can use it with B4A, B4J and B4i.
I am doing tests with B4J (much more direct, more comfortable debugging).