Some changes to convert to c++
Cleaned up unused variables.
merge master into branch