-graphs optimization, minor changes in functions