Better memory management

- Improved memory management