Refactoring, style fixes.
Added code snippets.