Add support for class member variable

supersedes #1417
The current code is a lot more verbose.

Actually, do you even need the name (className_)? Can't you just use `this`?