Fix basic.return stats, and fix various problems found by dialyzer.