reorganized the source and made new example that compiles on OSX 10.8.