Fixed major bug where neighbor calculation did not consider toroidal wrapping