added memory management improvements draft