Added type annotations and some more documentation