Simplify implementation of ctx_new