Refactor services into common library