Added bounds check to tiles coordinates, will avoid memory overwrite errors

Also added safe in Matrix.m to avoid over-indexing in array