Properly checking iterator returned key.
Removing unused variable.
Adding a separate stub generating class.