Make setPosition more robust.