Minor changes. Document non-obvious memory handling.