More graph stuff; merge in unit tests