Bug fixes: prevent calculation errors from trials=max grid remap, prevent runtime errors due to spsolve in edge cases