Fixed neighbor calculations to not wrap horizontally and be more efficient and clear