Changed the deinit call to an unref to prevent a wrong free
Merge pull request #383 from TheNeikos/fix-stack_free_in_cursor

Changed the deinit call to an unref to prevent a wrong free