some clean up. added support for adding relations. Yet to be UTed though.