Fixing a bug with addClassWait. Cleaning some code in script