[WIP] Cleaning up analyze.py

Addresses #128