- Main change is the usage of const_cast and reinterpret_cast instead of C-style type casts.
 - A lot of minor formatting changes done by clang-format (used version 3.8.1).
 - Changed type of several counters from unsigned to signed, as this is logical and also reduces the amount of needed casts.
 - Changed type of 32- and 64-bit bitwise intrinsics parameters from signed to unsigned.
 
Though the patch is big I tried to not change any functionality, just did the cleanup.
Any comments are welcome.