Fix leaked Cursor and InputStream