memory leaks in _type fixed