Fixed major bug in generation