Fixed the semantic deduction and memery deletion

Well, now , it should not have any mem-leak now.