Memory leak fix in 989b1523b1b516c501781e01cd9bce09ab5e122a