Tweaked code and added examples.

Change-Id: Ib38cc46493a5139ca29d84020650929d94cac850