Fixes to class-apply mechanism