A few leak fixes

See each commit separately.