Revert "Revert "rewrite using c++ and new design""

This reverts commit 187d5422223d7b09e13e78c8efd75f2feb88000c.

tower: https://tower.im/projects/8f19f0bf0e754f0b82ef2c24bc230973/todos/ab64a4ac2c914c7e9dbea25257a8cb9d/

Change-Id: I43cf8d3b532b1872c2511cb2371dee4b72b50731