Refactor ; create API and static lib