refactored analyzeq.py aggregate.py