Remove dead local variables
Fix regression
Restore Dispose() method
Fix regression
Merge pull request #2089 from ke-yu/code_cleanup

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