Refactor generation to be able to provide delegates