fixed file upload for multiple files, refactored code, fixed some bugs