From C++ best practices

Uses static_cast<> instead of C casting.
More static_cast<>
Merge pull request #3104 from ricardoquesada/static_cast_love

From C++ best practices