Fix some warnings

Raised warning level from 3 to 4 and fixed a few warnings.