Some bug fixes and modified examples