Fix some issues that cause clang warnings

Fixed warnings (found with -Weverything):
-Wmissing-variable-declarations
-Wshadow
-Wmissing-prototypes
-Wshorten-64-to-32
-Wconditional-uninitialized
-Wpadded
-Wconversion
-Wfloat-equal
-Wsign-conversion
-Wshift-sign-overflow