Fix for issue #13.

This fixes the crashes after a resolution switch as described in issue #13.