Refactor stats dump