refactor, and minor speed-up: push prefix and suffix search inside calcSplices