Refactor and fixed bounded generator