Add avoiding NPE, catch errors and enhance logging
Merge branch 'issue-nwbib-17-spatial-99' into merge_17-504