updates, fixed bugs, and added Cpp code