Fix some of the (many) compiler warnings

Most of these are fixes for harmless issues (i.e. comparison of unsigned
and signed ints). The only serious issues fixed were those in
Potential_v2.cpp.