fixing memleaks