fixed a memleak in internal.download()
fixed invalid unlocking