Refactore code generation to pass state across

the chain
Fix state passing across layers
Add more information to method descriptor
Implemented method signature upgrade and

refactored some API names