Added support for variables in indexing operators

Fixes #657