Made stats storing more robust