Fix swift segfault problem