Refactor to use StateP, new SourceDictCache type, restructured use of shutdown MVars