general improvements to generator functions