Move table layout calculations to a new file