Reduce the scope of a variable, and remove pointless memsets (the same memory is immediately overwritten by the subsequent memcpy)