avoid stack dumps on None
split stats gathering and printing