Fix boundaries moving and mem bug