Working version of generator. Added flag ENSURE_FAST_GENERATION