Fix some warnings; some potentially bad logic, some unreachable code. Clang still complains about potentially insecure strings.