Optimize output count to cache counts

Added caching in the data file for output and state counts so that output probability can run fast.