Add support for class member variable

supersedes #1417
Then you do not need the branch here.