A somewhat less dirty fix of the previous segfault