clean up the order of the generated classes, and add dot products