Merge of chaining, primitives and code clean up changes