Reusing closed cursors is bad for your health (SEGV), don't do that.
Also a bit of paranoia, bzero after all enif_alloc calls.