improved memory management