Draft implementation of the index lookup; issues with type inference