Refactor services and add libraries