Now uses static number of cursors and works. Needs clean up.