binman: Refactor fit to generate output at the end