Fixed names to correctly match structures.
Moved definitions closer to where they're used.
Updated file names in examples.