Updated with syntax highlighting and some tweaking of the code blocks.