Initialise possibly undefined variables

Change-Id: I095395e3b3e3514dc4e6fd5d905112da122a7418
Update docs and type hints

Change-Id: I6c513265d7e3136c43c160b86a83a921defaa3ec
Update indentation and newlines

Change-Id: Iac833df12a00949d32f2ce2fc26a657bab3d8229
Simplify return statement

Change-Id: I6a7a5c2aae4ead9c14208f67abf9f82ff71e165d