Still managed to get an occasional segfault with my previous commit, this change fixes the segfault