Properly cast density
Properly initialize variables
Merge branch 'bug-18105-fix-network-statistics'