Extracted AbstractChain class.

CongenericChain and BaseChain are now inheriting this new class.
Also changed iterators so they now use AbstractChain and BaseChain.