Fixes hanging issue on startup and segfault