Documentation cleanup

Fix bugs in the example code, typos etc.