Prevent `removeClass/addClass` from affecting window objects

Fixes #992, closes #996