cleaned up some graph handling code

No noticeable functional changes. Added some asserts so that
KDirStat-style drawing (rightfully) ASSERTs more often.
Refactored some CItem code