Fixed several GCC compile warnings

This commit takes care of pretty much all GCC compiler warnings. I've deliberately ignored all warnings about unused variables and parameters, because some of them might be needed in the future?