clear the unneeded classes and update corresponding code