fixed some edge cases with adding/removing classes