Added boundary check for terrain editing so there's no more array wraparound.  Fixes issue #9.