Added argument checks by asserts()
Now the field can be rectangular, not just a square.