Optimized stemfinding and overlap ratio calculations