Several performance improvements in the analysis script.