minor improvement to memory management