This thread may help.
Code of the teleportation example linked by @Srinivas_Prabhu there could also be useful.