Refactor server file.