Refactor/encapsulate chain globals into a CChain class