Fixed problems found by clang

Fixed warnings and errors from the clang compiler. None of these change any functionality.