Add "name" attribute to class.

Add "name" attribute to class + small logic fix.