More work on new optimization API