Fix crashes.

Fix a Divide by zero crash and NPE on view clear.
The other way is synchronise clear with this thread...