Factor out blockwriter.cc