ChartKBestExtractor: fix memory leak, clean-up code