Fix potential segfaults and unresolved breaks