Base implementation guided by Sean Chen.