Fixed several bugs that showed up in the examples.