[experiment] bug fixes and refactoring.