Caches are used in the listeners to mimic recursion stack and hold on to the correct variables. This seems to be a performance snag and potentially can be avoided by using a decorator pattern on the statistic. Each decorator can wrap a statistic to add variables needed for its computation and this wrapping can be done on the original statistic by the recursion when it registers them. This decoration can be done by an inline class from a static method in the listener class. This will simplify the listener code significantly as currently we need to look up the cache to do any processing.