clarifications/typo fixes/improved sample code

Updated REFERENCE.md with some more commented/useful sample code, and fixed some typos along the way.