Fixed a layout bug.

Fixed a bug that occurs while we are finding center of tree during
layout.