Fix crash when rotating screen

Fixes #3