Improve class variable handling