Added some casts to make it easier to include in a c++ project

I added some casts and 1 variable name change so this can be included in a c++ project more easily.