NULL check AppendVertex.
Refactoring.
Refactoring (contd)