Some refactoring in newCtx