E3-866: Type hints
This MR improves various type hints, but also has to do some refactoring and similar minor changes in order to achieve static typing.
This MR improves various type hints, but also has to do some refactoring and similar minor changes in order to achieve static typing.