Various fixes in generation