ScanR: fix well linkage issues (rebased onto develop)



This is the same as gh-444 but rebased onto develop.

----