More flexible API with context_id + plug optim in the right place