Simplified code in Example 2

Just some minor simplifications + improvements to the Example 2 code.