Rotate Around and Look At Problem

I'm using the following code to get prototype for moving an object around a spherical object and keeping the object perpendicular to the sphere.

var speed = 100.0;
var planet : Transform;

function Update () {
    var x = Input.GetAxis("Horizontal") * Time.deltaTime * speed *-1;
    transform.RotateAround(Vector3(0, -512, 0), Vector3.forward, x);
    transform.LookAt(planet);
}

The result is sort of working. I see the following behavior when the object orbiting crosses the halfway point of the sphere. It rotates 180 on the z axis.

alt text

Try this

LookAt(planet,Vector3(0,0,1));