Better use the "code" tag for scripts, otherwise they are hard to read here. When your model floats its position is probably set up wrong in MED, make sure that the origin is in the models center and not at its feet.