add missed memory management codes.