Add better memory management.