Add support for class member variable

supersedes #1417
Yes, but see later comments.