Add CPPCheck and fix warnings