Fix problem with class variables and change to mixin