Bugfixes for uploading files

- upload.xq should get rewritten from scratch