some fixes to improve the performance of segscan