Refactored Generators

Fixes #195, and should make the code more readable too.