Code cleanup: remove dead local variables and unnecessary cast in ProtoCore

This pull request removes dead local variables (those variables that get assigned but never used) and unnecessary casting -- the majority of unnecessary cast is casting ``MetatData.Type`` (whose type is ``int``) to ``int``, e.g., ``int type = (int)sv.MetaData.Type;``. 

Run language test cases to ensure no regression.