Fix Clang static analysis errors

This covers #459 and #460.