Fixed pointer bugs in sor.
Fixed merge conflict.