Simplified innerMostTemplateCertainlyEnclosingSfPos by using
compiler.locateIn(). Also, simplified another expression.