Implementing the to JSON method.
Adding missing comment.
Adding clear method to resolve undo/redo issues.