Fix most warnings
Fix double-free related to graph caching
some comments