Fix generation of class name refs #789