fixes
fixed memory management