Dialyzer fixes

A couple of fixes found by dialyzing the code