Fix some static analyser and compiler warnings