Essentially the same as patch 3/3 from v2 of this set, but split into two patches; one to improve the robustness of the freespace calculation, and then one to update all the various places that calculate free space to call the new improved code. See individual commit messages for more detail.