fixed some memory leaks and fixed a problem with spheres and planes not
correctly reporting their positions