Apex refcursors

Merge initial work with conversion process.