Small code restructuring. Added new example file.