Fixes for various compiler and static analysis warnings