Fixed memory leaks in ed().