Fix a bunch of Dialyzer warnings (some being actual bugs).