Refactor uibuf sizing