Added documentation and fixes to example