Type warnings

When compiling on a 64bit architecture there are many type warnings. 
Some even seem are errors, like inconsistent type for message id.

This fixes a few of these issues (not all).