Fix expand

Fixes two bugs in the expand feature
(1) incorrect computation of row expansion (Issue #2)
(2) incorrect handling of the border columns