fix potential memory leak
document the new behavior