ADD threshold.py and StateFinder