optimizations, new example, bug fixes, refactoring