bugfixes on code for graphs