Format code samples

I've tried to format the code samples to be clearer when displayed on GitHub. I had to break some of the longer ones over multiple lines.