Removed temporary files and refactored fileDownload