Refactor embedded server