Added generation functions
Some improvements