added links API for linking and unlinking objects, fixed some bugs