Refined the boundary checking. Also removed a vestigal function in the utilities