Intialise possible unset variables and add type hints

Also: A few typos in docs fixed.

Change-Id: I54309d4e9d4d0f7e91a9e5896a1c68a1006e3442