Edit: I made a mistake in my code, so that actually wasn't the real result. Below is the real result.
If you zoom in, you can see that the leaves don't look right. They are being cut off before the edges, although it alleviated the ghosty branches a little. That sounds reasonable because the pixels near the center of the leaves are more likely to still be within the leaves even with some displacement, but the edges are probably invading on space that's mostly sky.
The mistake I was making was pretty simple, and stupid. Instead of "result = tmp", I wrote "tmp = result". So each pixel in the noisy image you see below is the last well-exposed pixel in the stack, which is mostly the last image in the stack.
The simplest way to eliminate the stubborn traces of ghosting is to just ignore the lower weighted pixels, and this is the result of using only the pixels with the largest weights:
Not only did this eliminate the ghost person, it also completely eliminated the blurriness of the branches (click image for zoom in). However, the price to pay for this is a lot of noise. One of Khan algorithm's side benefits is that it eliminates noise by blending different images, so choosing a single image's pixel no longer gives that benefit. In anticipation of this, I tilted the initial weights to favor pixels near the brightness of 220/255, but that didn't seem to help. Maybe I didn't tilt the correct weights.