Remove unused globals, add some type-hinting

Change-Id: I9d257c6b149b0734a5b7ae312b16f109534923d3
Merge "Remove unused globals, add some type-hinting"