Fix refresh crash

Fixes #1348 (at least regarding the crash)