Make empties from Armature (arm2empty)

I am trying to rewrite script from “Blender Motion Kit” to Blender 2.5.
All fine until parenting empties. Objects changing positions.

Please, help.

http://www.pasteall.org/13295/python