Update for latest master and fix segfault