Fixed possible memory leak with result set