Handle constraint variables in class methods. Fixes #168.