Added dimension checking and support.

Still missing for function calls and arrays.