fixed #29: now correctly handles window resizing