Fixed some errors. Added 1st code snippet.