fixed memory/cursor leak in reader