Fix viewports

This time for good I hope.
Fixes #351.

I've added in a debug switch to enable dirty box view on viewports as well.