Refactor CPP. Add test samples.