[haiyang] big refactor