refactory, fix most bugs, add multipart support, add xauth