Fix crashes.

Fix a Divide by zero crash and NPE on view clear.