minor memory management improvements