Another memleak and some exception-safety.