Fix collapse and expand of graphs