Refactored paest.py into several parts.