Cleaned up generator code