Make add/removing classes more reliable.