cleanup cpp code for echopy