Hello,
Even if it can produce a less optimized result, it would fit to real needs to be able to choose the preferred "origin" corner for irregular problem types.
I changed the directions variable values there and it seems to do the job. Is it the right location to look ?