moved c files to cpp and some clean up