Refactor in serverScript and upload.coffee