Fix some swift problems

* fix get_or_create_sp() that may cause a dead lock