Sweep some code style

Add more comments with better XML convention.
Add necessary explanation.