Adds more uniform height calculation for ghost elements

This fix provides more consistent height calculation for ghost elements.