Implemented most of FinalStateAnalysis.