Added documentation and example
Modified example
Minor code cleanup