improved multipart handling