Added logic to make sure root during rotation parent object reference
also get changed.

Made some re-factoring