Code cleanup
Fix issue #703 and #704
Fix teleport serialization