Add support for class member variable

supersedes #1417
I'll try to see if I can fix it