Began porting python code to cpp