Various fixes for uploading file