calcSpan changed to use fewer loops, room removal now checks for the min/max spans of each z level.