Some cleanup; added generate capacity function for Java and C# generated code