Server scripts refactoring