stack.py separated from peaks.py