Clean-up some unnecessary CHECKVAL templates.
Move some unused includes.
Add overflow checking for CHECKVAL.
Fix issues with negative values and uint32.
Fix possible size issues.
Eluna fix doc style and prepare merge a PR
Fix merge conflicts
Merge commit '2e1ed8c1e92f3af12165112b333e63ace34bfe2a'