Start porting to cpp