Fix a memory leak and bugs in AddObj/AddCon