fix a few cursor leaks
use MetadataRetriever instead of BASTP