Make README and examples work again

It seems like the code was changed a bit without updating the relevant parts of documentation and examples. I fixed what I could spot. I'm pretty sure the code from `README.md` is correct now, but I didn't have much time to test example program thorougly.

Hope this helps.