In trying to understand the LDM, I came across a few places where I believe it's possible to leak memory. The first patch appears to just be a copy-paste bug, and 2-6 are all fixing the same fundamental problem, an explanation of which is given in 2/6.