Added proper type checking and support for indexing object arrays