Fix NPEs and support $ at the beginning of the name
clean the model *before* removing the classes
Fully load the classes that will be removed, to avoid exceptions when
cleaning caches in the using project
fix a wrong assert