Fix various bugs discovered with clang.
Add CI support.