Significant performance improvements to scan