Modifications to a) allow releasing of resources and b) custom generators