Remove dead code, unneeded casts and add annotations

* Dead code is what it says: imports that were not used and local variable initializers that were not needed
* Unneeded casts is self-explanatory
* Added `unchecked` annotations where types were not enforceable by the compiler
* Added `unused` annotations for items that the editor was not able to prove are in use