Improved drawing into a graph and fixed various bugs