Add support for class member variable

supersedes #1417
It is not clear to me why this is needed? Care to add a comment?