Added rotate3d and fixed a few bugs