Added array bounds checking.

Works for single and multi-dimensional arrays.

3D arrays seems to have some problem connected to generics that is
unrelated to bounds checking.