Add type hinting to functions

It's only reasonable to have proper type hinting here which might even help us to catch bugs.