Fix total data length bug