Assume a this pointer everywhere.

This wastes one variable slot in the main method - big deal :P
Also rename getNextIndex() -> getNumVariables().