Fixed bugs with border size calculation and direction of exchange