Code formatting and cleanup for clarity

Some updates to make it easy to read the source code for this example.