extended example and a few bug fixes