Cleanup metadata setting and add fix for multipart uploads. Closes #274.