Finalize stats creation and fix bug in import