Refactor loginserver and common