Added swift support and some bug fixed